diff options
author | Paul Phillips <paulp@improving.org> | 2012-10-01 07:12:25 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-10-01 07:15:29 -0700 |
commit | 81226b82d8c8b138eabb6956cab82410a17d812c (patch) | |
tree | 274f69cabfe3158818952d3ac15b99e4137fcb04 /test/files/run/collection-stacks.scala | |
parent | d2074796a8b822c4c82faecc8eb0eef4837508e3 (diff) | |
download | scala-81226b82d8c8b138eabb6956cab82410a17d812c.tar.gz scala-81226b82d8c8b138eabb6956cab82410a17d812c.tar.bz2 scala-81226b82d8c8b138eabb6956cab82410a17d812c.zip |
Recovered a bunch of deleted tests.
Are we in the habit of simply deleting tests when they
become inconvenient? A comment referenced test "0851" as the
example of why the code was needed; the test was deleted
years ago for no reason I can see except that it was not
passing at the time. Words fail me.
Public Service Announcement: tests which are failing are
the MOST USEFUL tests. DON'T DELETE THEM!
Diffstat (limited to 'test/files/run/collection-stacks.scala')
-rw-r--r-- | test/files/run/collection-stacks.scala | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/files/run/collection-stacks.scala b/test/files/run/collection-stacks.scala new file mode 100644 index 0000000000..fbee3f8594 --- /dev/null +++ b/test/files/run/collection-stacks.scala @@ -0,0 +1,38 @@ +import scala.collection.{ immutable, mutable } + +object Test extends Application { + 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) { + 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: |