aboutsummaryrefslogtreecommitdiff
path: root/tests/run/collection-stacks.scala
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2015-06-15 17:50:04 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-06-15 17:50:04 +0200
commit506a5e334d57084322fa89119d72fa96beb824b6 (patch)
tree83401f75400ac373e5ae68d633bbf9de2b6ce8d9 /tests/run/collection-stacks.scala
parentc4c29e393afb7175422053924b7e1e5a30131c4c (diff)
downloaddotty-506a5e334d57084322fa89119d72fa96beb824b6.tar.gz
dotty-506a5e334d57084322fa89119d72fa96beb824b6.tar.bz2
dotty-506a5e334d57084322fa89119d72fa96beb824b6.zip
Enable tests that succeed.
Diffstat (limited to 'tests/run/collection-stacks.scala')
-rw-r--r--tests/run/collection-stacks.scala38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/run/collection-stacks.scala b/tests/run/collection-stacks.scala
new file mode 100644
index 000000000..a41bef37c
--- /dev/null
+++ b/tests/run/collection-stacks.scala
@@ -0,0 +1,38 @@
+import scala.collection.{ immutable, mutable }
+
+object Test extends dotty.runtime.LegacyApp {
+ def mutableStack[T](xs: T*): mutable.Stack[T] = {
+ val s = new mutable.Stack[T]
+ s.pushAll(xs)
+ s
+ }
+
+ def immutableStack[T](xs: T*): immutable.Stack[T] = {
+ immutable.Stack.empty[T] pushAll xs
+ }
+
+ def check[T](expected: T, got: T): Unit = {
+ println(got + ": " + (expected == got))
+ }
+
+ // check #957
+ check("3-2-1", immutableStack(1, 2, 3).iterator.mkString("-"))
+ check("3-2-1", mutableStack(1, 2, 3).iterator.mkString("-"))
+
+ println("apply")
+ check(3, immutableStack(1, 2, 3).apply(0))
+ check(3, mutableStack(1, 2, 3).apply(0))
+ check(1, immutableStack(1, 2, 3).apply(2))
+ check(1, mutableStack(1, 2, 3).apply(2))
+
+ println("top")
+ check(3, immutableStack(1, 2, 3).top)
+ check(3, mutableStack(1, 2, 3).top)
+
+ println("pop")
+ check("2-1", immutableStack(1, 2, 3).pop.mkString("-"))
+ check(3, mutableStack(1, 2, 3).pop())
+ check("2-1", { val s = mutableStack(1, 2, 3); s.pop(); s.toList.mkString("-") })
+}
+
+// vim: set ts=2 sw=2 et: