diff options
author | Paul Phillips <paulp@improving.org> | 2011-05-19 20:06:19 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-05-19 20:06:19 +0000 |
commit | 4afa092314487c0095ff9fd5756d05340f6150b0 (patch) | |
tree | d3cf421e67192041f78858fe10735505f4891b3c /test/files/run/unittest_collection.scala | |
parent | 7595671ec3929aa4ac978826521300a900250214 (diff) | |
download | scala-4afa092314487c0095ff9fd5756d05340f6150b0.tar.gz scala-4afa092314487c0095ff9fd5756d05340f6150b0.tar.bz2 scala-4afa092314487c0095ff9fd5756d05340f6150b0.zip |
Removes SUnit (long deprecated!) from the stand...
Removes SUnit (long deprecated!) from the standard library.
the relatively small number of partest tests in Scala's suite that
were still using SUnit now either just use regular asserts, or they
print stuff that partest checks with a .check file. Also fixed some bad
indentation, removed ancient useless-looking commented-out code, etc.
Contributed by Seth Tisue (way to go seth) no review.
Diffstat (limited to 'test/files/run/unittest_collection.scala')
-rw-r--r-- | test/files/run/unittest_collection.scala | 123 |
1 files changed, 39 insertions, 84 deletions
diff --git a/test/files/run/unittest_collection.scala b/test/files/run/unittest_collection.scala index d45c23d4b5..822e2b0c98 100644 --- a/test/files/run/unittest_collection.scala +++ b/test/files/run/unittest_collection.scala @@ -1,103 +1,58 @@ - object Test { - import scala.testing.SUnit._ import scala.collection.mutable.{ArrayBuffer, Buffer, BufferProxy, ListBuffer} - trait BufferTest extends Assert { - def doTest(x:Buffer[String]) = { - // testing method += - x += "one" - assertEquals("retrieving 'one'", x(0), "one") - assertEquals("length A ", x.length, 1) - x += "two" - assertEquals("retrieving 'two'", x(1), "two") - assertEquals("length B ", x.length, 2) - - // testing method -= (removing last element) - x -= "two" - - assertEquals("length C ", x.length, 1) - - try { x(1); fail("no exception for removed element") } - catch { case i:IndexOutOfBoundsException => } - - try { x.remove(1); fail("no exception for removed element") } - catch { case i:IndexOutOfBoundsException => } - - x += "two2" - assertEquals("length D ", x.length, 2) - - // removing first element - x.remove(0) - assertEquals("length E ", x.length, 1) - - // toList - assertEquals("toList ", x.toList, List("two2")) - - // clear - x.clear - assertEquals("length F ", x.length, 0) - - // copyToBuffer - x += "a" - x += "b" - val dest = new ArrayBuffer[String] - x copyToBuffer dest - assertEquals("dest", List("a", "b"), dest.toList) - assertEquals("source", List("a", "b"), x.toList) + def main(args: Array[String]) { + test(collection.mutable.ArrayBuffer[String]()) + test(collection.mutable.ListBuffer[String]()) + class BBuf(z:ListBuffer[String]) extends BufferProxy[String] { + def self = z } + test(new BBuf(collection.mutable.ListBuffer[String]())) } - class TArrayBuffer extends TestCase("collection.mutable.ArrayBuffer") with Assert with BufferTest { - - var x: ArrayBuffer[String] = _ + def test(x: Buffer[String]) { + // testing method += + x += "one" + assert(x(0) == "one", "retrieving 'one'") + assert(x.length == 1, "length A") + x += "two" + assert(x(1) == "two", "retrieving 'two'") + assert(x.length == 2, "length B") - override def runTest = { setUp; doTest(x); tearDown } + // testing method -= (removing last element) + x -= "two" - override def setUp = { x = new scala.collection.mutable.ArrayBuffer } + assert(x.length == 1, "length C") - override def tearDown = { x.clear; x = null } - } + try { x(1); sys.error("no exception for removed element") } + catch { case i:IndexOutOfBoundsException => } - class TListBuffer extends TestCase("collection.mutable.ListBuffer") with Assert with BufferTest { + try { x.remove(1); sys.error("no exception for removed element") } + catch { case i:IndexOutOfBoundsException => } - var x: ListBuffer[String] = _ + x += "two2" + assert(x.length == 2, "length D") - override def runTest = { setUp; doTest(x); tearDown } + // removing first element + x.remove(0) + assert(x.length == 1, "length E") - override def setUp = { x = new scala.collection.mutable.ListBuffer } + // toList + assert(x.toList == List("two2"), "toList") - override def tearDown = { x.clear; x = null } + // clear + x.clear() + assert(x.length == 0, "length 0") + assert(x.isEmpty, "isEmpty") + // copyToBuffer + x += "a" + x += "b" + val dest = new ArrayBuffer[String] + x.copyToBuffer(dest) + assert(List("a", "b") == dest.toList, "dest") + assert(List("a", "b") == x.toList, "source") } - class TBufferProxy extends TestCase("collection.mutable.BufferProxy") with Assert with BufferTest { - - class BBuf(z:ListBuffer[String]) extends BufferProxy[String] { - def self = z - } - - var x: BufferProxy[String] = _ - - override def runTest = { setUp; doTest(x); tearDown } - - override def setUp = { x = new BBuf(new scala.collection.mutable.ListBuffer) } - - override def tearDown = { x.clear; x = null } - - } - - def main(args:Array[String]) = { - val ts = new TestSuite( - //new TArrayBuffer, - new TListBuffer//, - //new TBufferProxy - ) - val tr = new TestResult() - ts.run(tr) - for (failure <- tr.failures) { - Console.println(failure) - } - } } |