diff options
author | Paul Phillips <paulp@improving.org> | 2009-05-09 03:53:41 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-05-09 03:53:41 +0000 |
commit | 2ea3b94ee2519e01a3e1658909afeb33e7e9ebe2 (patch) | |
tree | 9bb2044c595fe260c352a00cf98bb2ecece50437 /test/disabled/run/unittest_collection.scala | |
parent | f7ab13b08e085c3bf94d857fc9648ee724e4cb08 (diff) | |
download | scala-2ea3b94ee2519e01a3e1658909afeb33e7e9ebe2.tar.gz scala-2ea3b94ee2519e01a3e1658909afeb33e7e9ebe2.tar.bz2 scala-2ea3b94ee2519e01a3e1658909afeb33e7e9ebe2.zip |
Organized disabled directory so it works with p...
Organized disabled directory so it works with partest. You can run
./partest --srcpath disabled to run the tests in that location. Fixed a
few tests in disabled and pending and moved to files.
Diffstat (limited to 'test/disabled/run/unittest_collection.scala')
-rw-r--r-- | test/disabled/run/unittest_collection.scala | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/test/disabled/run/unittest_collection.scala b/test/disabled/run/unittest_collection.scala new file mode 100644 index 0000000000..5d7ab97425 --- /dev/null +++ b/test/disabled/run/unittest_collection.scala @@ -0,0 +1,103 @@ + +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) + } + } + + class TArrayBuffer extends TestCase("collection.mutable.ArrayBuffer") with Assert with BufferTest { + + var x: ArrayBuffer[String] = _ + + override def runTest = { setUp; doTest(x); tearDown } + + override def setUp = { x = new scala.collection.mutable.ArrayBuffer } + + override def tearDown = { x.clear; x = null } + } + + class TListBuffer extends TestCase("collection.mutable.ListBuffer") with Assert with BufferTest { + + var x: ListBuffer[String] = _ + + override def runTest = { setUp; doTest(x); tearDown } + + override def setUp = { x = new scala.collection.mutable.ListBuffer } + + override def tearDown = { x.clear; x = null } + + } + + 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(val failure <- tr.failures) { + Console.println(failure) + } + } +} |