diff options
Diffstat (limited to 'test')
26 files changed, 329 insertions, 12 deletions
diff --git a/test/files/jvm/inner.scala b/test/files/jvm/inner.scala index c05e803449..dc01b124c5 100644 --- a/test/files/jvm/inner.scala +++ b/test/files/jvm/inner.scala @@ -77,7 +77,7 @@ object Scalatest { def java(cname: String) = exec(javacmd, "-cp", classpath, cname) - /** Execute cmd, wait for the process to end and pipe it's output to stdout */ + /** Execute cmd, wait for the process to end and pipe its output to stdout */ private def exec(args: String*) { val proc = Runtime.getRuntime().exec(args.toArray) val inp = new BufferedReader(new InputStreamReader(proc.getInputStream)) diff --git a/test/files/jvm/javaReflection/Test.scala b/test/files/jvm/javaReflection/Test.scala index 5b6ef1b573..ae5a36eeb2 100644 --- a/test/files/jvm/javaReflection/Test.scala +++ b/test/files/jvm/javaReflection/Test.scala @@ -124,8 +124,8 @@ object Test { // exclude files from Test.scala, just take those from Classes_1.scala case s if !s.startsWith("Test") && s.endsWith(".class") => s.substring(0, s.length - 6) }).sortWith((a, b) => { - // sort such that first there are all anonymous funcitions, then all other classes. - // within those cathegories, sort lexically. + // sort such that first there are all anonymous functions, then all other classes. + // within those categories, sort lexically. // this makes the check file smaller: it differs for anonymous functions between -Ydelambdafy:inline/method. // the other classes are the same. if (isAnonFunClassName(a)) !isAnonFunClassName(b) || a < b diff --git a/test/files/neg/virtpatmat_exhaust_big.check b/test/files/neg/virtpatmat_exhaust_big.check new file mode 100644 index 0000000000..fddc85a362 --- /dev/null +++ b/test/files/neg/virtpatmat_exhaust_big.check @@ -0,0 +1,7 @@ +virtpatmat_exhaust_big.scala:27: warning: match may not be exhaustive. +It would fail on the following input: Z11() + def foo(z: Z) = z match { + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/virtpatmat_exhaust_big.flags b/test/files/neg/virtpatmat_exhaust_big.flags new file mode 100644 index 0000000000..b5a8748652 --- /dev/null +++ b/test/files/neg/virtpatmat_exhaust_big.flags @@ -0,0 +1 @@ +-Xfatal-warnings -unchecked diff --git a/test/files/neg/virtpatmat_exhaust_big.scala b/test/files/neg/virtpatmat_exhaust_big.scala new file mode 100644 index 0000000000..dd639eb56e --- /dev/null +++ b/test/files/neg/virtpatmat_exhaust_big.scala @@ -0,0 +1,32 @@ +sealed abstract class Z +object Z { + object Z0 extends Z + case class Z1() extends Z + object Z2 extends Z + case class Z3() extends Z + object Z4 extends Z + case class Z5() extends Z + object Z6 extends Z + case class Z7() extends Z + object Z8 extends Z + case class Z9() extends Z + object Z10 extends Z + case class Z11() extends Z + object Z12 extends Z + case class Z13() extends Z + object Z14 extends Z + case class Z15() extends Z + object Z16 extends Z + case class Z17() extends Z + object Z18 extends Z + case class Z19() extends Z +} + +object Test { + import Z._ + def foo(z: Z) = z match { + case Z0 | Z1() | Z2 | Z3() | Z4 | Z5() | Z6 | Z7() | Z8 | Z9() | + Z10 | Z12 | Z13() | Z14 | Z15() | Z16 | Z17() | Z18 | Z19() + => + } +} diff --git a/test/files/pos/t7815.scala b/test/files/pos/t7815.scala index 12a434c5b0..0a126f9faa 100644 --- a/test/files/pos/t7815.scala +++ b/test/files/pos/t7815.scala @@ -21,7 +21,7 @@ object Foo { object Main extends App { def mapWithFoo[A <: AnyRef, B](as: List[A])(implicit foo: Foo.Aux[A, B]) = { // Should be Eta expandable because the result type of `f` is not - // dependant on the value, it is just `B`. + // dependent on the value, it is just `B`. as map foo.f as map foo.g as map foo.m diff --git a/test/files/pos/t9285.flags b/test/files/pos/t9285.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/pos/t9285.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/pos/t9285.scala b/test/files/pos/t9285.scala new file mode 100644 index 0000000000..b7146cdf1c --- /dev/null +++ b/test/files/pos/t9285.scala @@ -0,0 +1 @@ +case class C(placeholder: Unit) diff --git a/test/files/pos/virtpatmat_exhaust_big.scala b/test/files/pos/virtpatmat_exhaust_big.scala new file mode 100644 index 0000000000..9850933540 --- /dev/null +++ b/test/files/pos/virtpatmat_exhaust_big.scala @@ -0,0 +1,33 @@ +sealed abstract class Z +object Z { + object Z0 extends Z + case class Z1() extends Z + object Z2 extends Z + case class Z3() extends Z + object Z4 extends Z + case class Z5() extends Z + object Z6 extends Z + case class Z7() extends Z + object Z8 extends Z + case class Z9() extends Z + object Z10 extends Z + case class Z11() extends Z + object Z12 extends Z + case class Z13() extends Z + object Z14 extends Z + case class Z15() extends Z + object Z16 extends Z + case class Z17() extends Z + object Z18 extends Z + case class Z19() extends Z +} + +// drop any case and it will report an error +object Test { + import Z._ + def foo(z: Z) = z match { + case Z0 | Z1() | Z2 | Z3() | Z4 | Z5() | Z6 | Z7() | Z8 | Z9() | + Z10 | Z11() | Z12 | Z13() | Z14 | Z15() | Z16 | Z17() | Z18 | Z19() + => + } +}
\ No newline at end of file diff --git a/test/files/run/classfile-format-51.scala b/test/files/run/classfile-format-51.scala index 24b1ee8397..7523130afa 100644 --- a/test/files/run/classfile-format-51.scala +++ b/test/files/run/classfile-format-51.scala @@ -12,7 +12,7 @@ import Opcodes._ // it runs a normal compile on the source in the 'code' field that refers to // DynamicInvoker. Any failure will be dumped to std out. // -// By it's nature the test can only work on JDK 7+ because under JDK 6 some of the +// By its nature the test can only work on JDK 7+ because under JDK 6 some of the // classes referred to by DynamicInvoker won't be available and DynamicInvoker won't // verify. So the test includes a version check that short-circuites the whole test // on JDK 6 diff --git a/test/files/run/classfile-format-52.scala b/test/files/run/classfile-format-52.scala index e12c84124c..453f61ac84 100644 --- a/test/files/run/classfile-format-52.scala +++ b/test/files/run/classfile-format-52.scala @@ -11,7 +11,7 @@ import Opcodes._ // HasDefaultMethod. Then it runs a normal compile on Scala source that extends that // interface. Any failure will be dumped to std out. // -// By it's nature the test can only work on JDK 8+ because under JDK 7- the +// By its nature the test can only work on JDK 8+ because under JDK 7- the // interface won't verify. object Test extends DirectTest { override def extraSettings: String = "-optimise -usejavacp -d " + testOutput.path + " -cp " + testOutput.path diff --git a/test/files/run/t7741a/Test.scala b/test/files/run/t7741a/Test.scala index a75cb6c9eb..cdba1cccf8 100644 --- a/test/files/run/t7741a/Test.scala +++ b/test/files/run/t7741a/Test.scala @@ -25,7 +25,7 @@ object Test extends DirectTest { // interface GroovyInterface { // // // This is the line that causes scalac to choke. - // // It results in a GroovyInterface$1 class, which is a non-static inner class but it's constructor does not + // // It results in a GroovyInterface$1 class, which is a non-static inner class but its constructor does not // // include the implicit parameter that is the immediate enclosing instance. // // See http://jira.codehaus.org/browse/GROOVY-7312 // // diff --git a/test/files/run/t9268.check b/test/files/run/t9268.check new file mode 100644 index 0000000000..90ef940eb3 --- /dev/null +++ b/test/files/run/t9268.check @@ -0,0 +1,5 @@ +Compiling Client1 +pos: NoPosition Class Waiter not found - continuing with a stub. WARNING +Compiling Client2 +pos: NoPosition Class Waiter not found - continuing with a stub. WARNING +pos: NoPosition Unable to locate class corresponding to inner class entry for Predicate in owner Waiter ERROR diff --git a/test/files/run/t9268/Java.java b/test/files/run/t9268/Java.java new file mode 100644 index 0000000000..c9a0bec3ff --- /dev/null +++ b/test/files/run/t9268/Java.java @@ -0,0 +1,12 @@ +public class Java { +} + +class Partial { + public <E extends java.lang.Exception> long waitFor(long l, Waiter.Predicate<E> pred) throws E { + return 0L; + } +} + +class Waiter { + interface Predicate<E> {} +} diff --git a/test/files/run/t9268/Test.scala b/test/files/run/t9268/Test.scala new file mode 100644 index 0000000000..813cbe7b60 --- /dev/null +++ b/test/files/run/t9268/Test.scala @@ -0,0 +1,40 @@ +import scala.tools.partest._ +import java.io.File + +object Test extends StoreReporterDirectTest { + def code = ??? + + def compileCode(code: String) = { + val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") + compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(code) + } + + def client1 = """ + class Client1 { def p(p: Partial) = p.toString } + """ + + def client2 = """ + class Client2 { def p(p: Partial) = p.waitFor() } + """ + + def deleteClass(s: String) = { + val f = new File(testOutput.path, s + ".class") + assert(f.exists) + f.delete() + } + + def show(): Unit = { + deleteClass("Waiter") + deleteClass("Waiter$Predicate") + + // Used to crash in Java Generic Signature parsing + println("Compiling Client1") + compileCode(client1) + println(storeReporter.infos.mkString("\n")) + storeReporter.reset() + println("Compiling Client2") + compileCode(client2) + println(storeReporter.infos.mkString("\n")) + } +} + diff --git a/test/files/run/valueClassSelfType.scala b/test/files/run/valueClassSelfType.scala new file mode 100644 index 0000000000..47a3764b0a --- /dev/null +++ b/test/files/run/valueClassSelfType.scala @@ -0,0 +1,52 @@ +trait T + +class V1(val l: Long) extends AnyVal { self: T => + def foo: V1 = self + def bar: T = self +} + +class V2(val l: Long) extends AnyVal { self => + def foo: V2 = self +} + +class V3(val l: Long) extends AnyVal { self: Long => + def foo: V3 = self + def bar: Long = self +} + +// non-value classes + +class C1(val l: Long) { self: T => + def foo: C1 = self + def bar: T = self +} + +class C2(val l: Long) { self => + def foo: C2 = self +} + +class C3(val l: Long) { self: Long => + def foo: C3 = self + def bar: Long = self +} + +object Test extends App { + // Rejected: superclass V1 is not a subclass of the superclass Object of the mixin trait T + // new V1(1l) with T + + assert(new V2(1l).foo.l == 1l) + + // Rejected: V3 does not conform to its self-type V3 with Long + // new V3(1l) + + val c2 = new C1(2l) with T + assert(c2.foo.l + c2.bar.asInstanceOf[C1].l == 4l) + + assert(new C2(3l).foo.l == 3l) + + // Rejected: C3 does not conform to its self-type C3 with Long + // new C3(4l) + + // Rejected: class Long needs to be a trait to be mixed in + // new C3(4l) with Long +} 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_+") + } } diff --git a/test/pending/jvm/javasigs.scala b/test/pending/jvm/javasigs.scala index 8da59ab0a0..d18a4e6fb5 100644 --- a/test/pending/jvm/javasigs.scala +++ b/test/pending/jvm/javasigs.scala @@ -32,7 +32,7 @@ object Scalatest { } - /** Execute cmd, wait for the process to end and pipe it's output to stdout */ + /** Execute cmd, wait for the process to end and pipe its output to stdout */ def exec(cmd: String) { val proc = Runtime.getRuntime().exec(cmd) val inp = new BufferedReader(new InputStreamReader(proc.getInputStream)) diff --git a/test/scaladoc/resources/SI-4476.scala b/test/scaladoc/resources/SI-4476.scala new file mode 100644 index 0000000000..eb35ef45e7 --- /dev/null +++ b/test/scaladoc/resources/SI-4476.scala @@ -0,0 +1,9 @@ +package foo + +@deprecated("","") +class A + +class B { + @deprecated("","") + def bar = 1 +} diff --git a/test/scaladoc/resources/Trac4420.scala b/test/scaladoc/resources/Trac4420.scala index dbe053f3da..d8e207876b 100644 --- a/test/scaladoc/resources/Trac4420.scala +++ b/test/scaladoc/resources/Trac4420.scala @@ -1,7 +1,7 @@ import java.io.File /** - * @define PP This class is an instance of XXX so it's members are not called directly. + * @define PP This class is an instance of XXX so its members are not called directly. * Instead these classes are instantiated via a driver's ''process''. See YYY for more details. */ abstract class test diff --git a/test/scaladoc/scalacheck/DeprecatedIndexTest.scala b/test/scaladoc/scalacheck/DeprecatedIndexTest.scala new file mode 100644 index 0000000000..4a5a2001d4 --- /dev/null +++ b/test/scaladoc/scalacheck/DeprecatedIndexTest.scala @@ -0,0 +1,50 @@ +import org.scalacheck._ +import org.scalacheck.Prop._ + +import scala.tools.nsc.doc +import scala.tools.nsc.doc.html.page.DeprecatedIndex +import java.net.{URLClassLoader, URLDecoder} + +object Test extends Properties("IndexScript") { + + def getClasspath = { + // these things can be tricky + // this test previously relied on the assumption that the current thread's classloader is an url classloader and contains all the classpaths + // does partest actually guarantee this? to quote Leonard Nimoy: The answer, of course, is no. + // this test _will_ fail again some time in the future. + // Footnote: java.lang.ClassCastException: org.apache.tools.ant.loader.AntClassLoader5 cannot be cast to java.net.URLClassLoader + val loader = Thread.currentThread.getContextClassLoader.asInstanceOf[URLClassLoader] + val paths = loader.getURLs.map(u => URLDecoder.decode(u.getPath)) + paths mkString java.io.File.pathSeparator + } + + val docFactory = { + val settings = new doc.Settings({Console.err.println(_)}) + settings.scaladocQuietRun = true + settings.nowarn.value = true + settings.classpath.value = getClasspath + val reporter = new scala.tools.nsc.reporters.ConsoleReporter(settings) + new doc.DocFactory(reporter, settings) + } + + val indexModelFactory = doc.model.IndexModelFactory + + def createDeprecatedScript(path: String) = + docFactory.makeUniverse(Left(List(path))) match { + case Some(universe) => { + val index = new DeprecatedIndex(universe, indexModelFactory.makeIndex(universe)) + Some(index) + } + case _ => + None + } + + property("deprecated-list page lists deprecated members") = { + createDeprecatedScript("test/scaladoc/resources/SI-4476.scala") match { + case Some(p) => + p.deprecatedEntries.find(_._1 == "A").isDefined && + p.deprecatedEntries.find(_._1 == "bar").isDefined + case None => false + } + } +} diff --git a/test/scaladoc/scalacheck/IndexTest.scala b/test/scaladoc/scalacheck/IndexTest.scala index abc0e5da01..7dbd2103a6 100644 --- a/test/scaladoc/scalacheck/IndexTest.scala +++ b/test/scaladoc/scalacheck/IndexTest.scala @@ -71,7 +71,7 @@ object Test extends Properties("Index") { case None => false } } - property("browser contants a script element") = { + property("browser contains a script element") = { createIndex("src/scaladoc/scala/tools/nsc/doc/html/page/Index.scala") match { case Some(index) => (index.browser \ "script").size == 1 @@ -86,4 +86,10 @@ object Test extends Properties("Index") { case None => false } } + property("index should report if there are deprecated members") = { + createIndex("test/scaladoc/resources/SI-4476.scala") match { + case Some(indexPage) => indexPage.index.hasDeprecatedMembers + case None => false + } + } } |