summaryrefslogtreecommitdiff
path: root/test/junit
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2015-05-01 15:33:30 +1000
committerJason Zaugg <jzaugg@gmail.com>2015-05-01 15:33:30 +1000
commite596d1a65d81a81a54847d90d2d90be3ffbb3d92 (patch)
treed6c86e80b08b47271e65bccfe734e80bc531be8f /test/junit
parent4210262867a541d4cbf0aaf2b06bedeef9520c2b (diff)
parent6a185e3c97b79716576725f1ecf0ba629e83951d (diff)
downloadscala-e596d1a65d81a81a54847d90d2d90be3ffbb3d92.tar.gz
scala-e596d1a65d81a81a54847d90d2d90be3ffbb3d92.tar.bz2
scala-e596d1a65d81a81a54847d90d2d90be3ffbb3d92.zip
Merge remote-tracking branch 'origin/2.11.x' into merge/2.11.x-to-2.12.x-20150501
Diffstat (limited to 'test/junit')
-rw-r--r--test/junit/scala/collection/mutable/UnrolledBufferTest.scala25
-rw-r--r--test/junit/scala/collection/mutable/VectorTest.scala1
-rw-r--r--test/junit/scala/concurrent/duration/SerializationTest.scala24
-rw-r--r--test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala2
-rw-r--r--test/junit/scala/tools/nsc/interpreter/TabulatorTest.scala20
5 files changed, 70 insertions, 2 deletions
diff --git a/test/junit/scala/collection/mutable/UnrolledBufferTest.scala b/test/junit/scala/collection/mutable/UnrolledBufferTest.scala
new file mode 100644
index 0000000000..8660b6cbc1
--- /dev/null
+++ b/test/junit/scala/collection/mutable/UnrolledBufferTest.scala
@@ -0,0 +1,25 @@
+package scala.collection.mutable
+
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.Test
+
+@RunWith(classOf[JUnit4])
+class UnrolledBufferTestTest {
+ @Test
+ def test_SI9254_original() {
+ val b = new UnrolledBuffer[Int]()
+ (1 to 16).foreach(i => b append i)
+ b.insert(0,-1)
+ b append 17
+ assert(b sameElements (Seq(-1) ++ (1 to 16) ++ Seq(17)))
+ }
+
+ @Test
+ def test_SI9254_additional() {
+ val b = new UnrolledBuffer[Int]()
+ (1 to 100).foreach(i => b append i)
+ b.insert(40, -1)
+ assert(b sameElements((1 to 40) ++ Seq(-1) ++ (41 to 100)))
+ }
+}
diff --git a/test/junit/scala/collection/mutable/VectorTest.scala b/test/junit/scala/collection/mutable/VectorTest.scala
index e9c4d44a72..b3219d1b02 100644
--- a/test/junit/scala/collection/mutable/VectorTest.scala
+++ b/test/junit/scala/collection/mutable/VectorTest.scala
@@ -38,7 +38,6 @@ class VectorTest {
def iteratorCat() {
def its = vecs.map(_.toList.toIterator)
val cats = vecs.map(a => its.map(a ++ _))
- println(cats)
assert( cats == ans )
}
diff --git a/test/junit/scala/concurrent/duration/SerializationTest.scala b/test/junit/scala/concurrent/duration/SerializationTest.scala
new file mode 100644
index 0000000000..af90a10984
--- /dev/null
+++ b/test/junit/scala/concurrent/duration/SerializationTest.scala
@@ -0,0 +1,24 @@
+package scala.concurrent.duration
+
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.Test
+
+
+@RunWith(classOf[JUnit4])
+class SerializationTest {
+ @Test
+ def test_SI9197 {
+ def ser(a: AnyRef): Array[Byte] = {
+ val bais = new java.io.ByteArrayOutputStream
+ (new java.io.ObjectOutputStream(bais)).writeObject(a)
+ bais.toByteArray
+ }
+ def des(ab: Array[Byte]): AnyRef =
+ (new java.io.ObjectInputStream(new java.io.ByteArrayInputStream(ab))).readObject
+
+ assert(Duration.Undefined eq des(ser(Duration.Undefined)))
+ assert(Duration.Inf eq des(ser(Duration.Inf)))
+ assert(Duration.MinusInf eq des(ser(Duration.MinusInf)))
+ }
+}
diff --git a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
index 17724aecb1..0fc3601603 100644
--- a/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
+++ b/test/junit/scala/tools/nsc/backend/jvm/opt/InlinerTest.scala
@@ -720,7 +720,7 @@ class InlinerTest extends ClearAfterClass {
|final class D extends C
|object E extends C
|class T {
- | def t1(d: D) = d.f + d.g + E.f + E.g // d.f can be inlined because the reciever type is D, which is final.
+ | def t1(d: D) = d.f + d.g + E.f + E.g // d.f can be inlined because the receiver type is D, which is final.
|} // so d.f can be resolved statically. same for E.f
""".stripMargin
val List(c, d, e, eModule, t) = compile(code)
diff --git a/test/junit/scala/tools/nsc/interpreter/TabulatorTest.scala b/test/junit/scala/tools/nsc/interpreter/TabulatorTest.scala
index 21e338eac0..263265026a 100644
--- a/test/junit/scala/tools/nsc/interpreter/TabulatorTest.scala
+++ b/test/junit/scala/tools/nsc/interpreter/TabulatorTest.scala
@@ -82,4 +82,24 @@ class TabulatorTest {
assert(rows(0).size == 1)
assert(rows(0)(0).size == "efg".length + sut.marginSize) // 6
}
+ @Test def badFit() = {
+ val sut = VTabby(isAcross = true)
+ val items = ('a' until 'z').map(_.toString).toList
+ val rows = sut tabulate items
+ assert(rows.size == 2)
+ assert(rows(0).size == 20) // 20 * 4 = 80
+ assert(rows(1)(0).dropRight(sut.marginSize) == "u")
+ }
+ @Test def badFitter() = {
+ val sut = VTabby(isAcross = true)
+ val items = List (
+ "%", "&", "*", "+", "-", "/", ">", ">=", ">>", ">>>", "^",
+ "asInstanceOf", "isInstanceOf", "toByte", "toChar", "toDouble", "toFloat",
+ "toInt", "toLong", "toShort", "toString", "unary_+", "unary_-", "unary_~", "|"
+ )
+ val rows = sut tabulate items
+ assert(rows.size == 4)
+ assert(rows(3).size == 4) // 7 cols
+ assert(rows(3)(0).dropRight(sut.marginSize) == "unary_+")
+ }
}