diff options
author | Rex Kerr <ichoran@gmail.com> | 2013-12-02 15:00:20 -0800 |
---|---|---|
committer | Rex Kerr <ichoran@gmail.com> | 2013-12-02 15:00:20 -0800 |
commit | 03bf97e0893b227812125f7c049fdac254181cb2 (patch) | |
tree | 6107017bc3885c0f60c5348d8185c5c749371d7a /test | |
parent | 6c63ab153651f7946ece5740d52e0f2b701e349d (diff) | |
download | scala-03bf97e0893b227812125f7c049fdac254181cb2.tar.gz scala-03bf97e0893b227812125f7c049fdac254181cb2.tar.bz2 scala-03bf97e0893b227812125f7c049fdac254181cb2.zip |
Fixes SI-8014, regression in Vector ++ TraversableOnce.
Now uses the cached copy instead of the exhausted iterator. Adds a JUnit
test for ++.
Diffstat (limited to 'test')
-rw-r--r-- | test/junit/scala/collection/VectorTest.scala | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/junit/scala/collection/VectorTest.scala b/test/junit/scala/collection/VectorTest.scala new file mode 100644 index 0000000000..e9c4d44a72 --- /dev/null +++ b/test/junit/scala/collection/VectorTest.scala @@ -0,0 +1,51 @@ +package scala.collection.mutable + +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 +import org.junit.Test +import scala.collection.mutable + +@RunWith(classOf[JUnit4]) +/* Test for SI-8014 and ++ in general */ +class VectorTest { + val noVec = Vector.empty[Int] + val smallVec = Vector.range(0,3) + val bigVec = Vector.range(0,64) + val smsm = Vector.tabulate(2 * smallVec.length)(i => (i % smallVec.length)) + val smbig = Vector.tabulate(smallVec.length + bigVec.length)(i => + if (i < smallVec.length) i else i - smallVec.length + ) + val bigsm = Vector.tabulate(smallVec.length + bigVec.length)(i => + if (i < bigVec.length) i else i - bigVec.length + ) + val bigbig = Vector.tabulate(2 * bigVec.length)(i => (i % bigVec.length)) + + + val vecs = List(noVec, smallVec, bigVec) + val ans = List( + vecs, + List(smallVec, smsm, smbig), + List(bigVec, bigsm, bigbig) + ) + + @Test + def vectorCat() { + val cats = vecs.map(a => vecs.map(a ++ _)) + assert( cats == ans ) + } + + @Test + def iteratorCat() { + def its = vecs.map(_.toList.toIterator) + val cats = vecs.map(a => its.map(a ++ _)) + println(cats) + assert( cats == ans ) + } + + @Test + def arrayCat() { + val ars = vecs.map(_.toArray) + val cats = vecs.map(a => ars.map(a ++ _)) + assert( cats == ans ) + } +} |