summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
Diffstat (limited to 'test/files')
-rw-r--r--test/files/codelib/.gitignore1
-rw-r--r--test/files/jvm/bytecode-test-example/Foo_1.flags1
-rw-r--r--test/files/jvm/nooptimise/Foo_1.flags2
-rw-r--r--test/files/jvm/scala-concurrent-tck.check3
-rw-r--r--test/files/jvm/scala-concurrent-tck.scala562
-rw-r--r--test/files/lib/.gitignore8
-rw-r--r--test/files/neg/case-collision.flags2
-rw-r--r--test/files/neg/case-collision2.check12
-rw-r--r--test/files/neg/case-collision2.flags1
-rw-r--r--test/files/neg/case-collision2.scala12
-rw-r--r--test/files/neg/names-defaults-neg.check9
-rw-r--r--test/files/neg/t1181.check6
-rw-r--r--test/files/neg/t556.check4
-rw-r--r--test/files/neg/valueclasses-impl-restrictions.check8
-rw-r--r--test/files/neg/valueclasses-impl-restrictions.scala4
-rw-r--r--test/files/pos/SI-7638.scala51
-rw-r--r--test/files/pos/t3936/BlockingQueue.java3
-rw-r--r--test/files/pos/t3936/Queue.java2
-rw-r--r--test/files/pos/t3936/Test.scala4
-rw-r--r--test/files/pos/t6221.scala29
-rw-r--r--test/files/pos/t7591/Demo.scala83
-rw-r--r--test/files/run/stream_length.check5
-rw-r--r--test/files/run/stream_length.scala6
-rw-r--r--test/files/run/t4294.scala7
-rw-r--r--test/files/run/t5603.scala2
-rw-r--r--test/files/run/t6221.check1
-rw-r--r--test/files/run/t6221/Macros_1.scala22
-rw-r--r--test/files/run/t6221/Test_2.scala10
-rw-r--r--test/files/run/t6308.scala20
-rw-r--r--test/files/run/t6331.scala7
-rw-r--r--test/files/run/t6331b.scala9
-rw-r--r--test/files/run/t7008-scala-defined.flags1
-rw-r--r--test/files/run/t7271.scala3
-rw-r--r--test/files/run/t7337.scala2
-rw-r--r--test/files/run/t7439/Test_2.scala3
-rw-r--r--test/files/run/t7571.scala12
-rw-r--r--test/files/run/t7582-private-within.check12
-rw-r--r--test/files/run/t7582-private-within/JavaPackagePrivate.java8
-rw-r--r--test/files/run/t7582-private-within/Test.scala22
-rw-r--r--test/files/run/t7582.check2
-rw-r--r--test/files/run/t7582.flags1
-rw-r--r--test/files/run/t7582/InlineHolder.scala16
-rw-r--r--test/files/run/t7582/PackageProtectedJava.java6
-rw-r--r--test/files/run/t7582b.check2
-rw-r--r--test/files/run/t7582b.flags1
-rw-r--r--test/files/run/t7582b/InlineHolder.scala16
-rw-r--r--test/files/run/t7582b/PackageProtectedJava.java6
-rw-r--r--test/files/scalacheck/si4147.scala5
-rw-r--r--test/files/scalacheck/treeset.scala3
-rw-r--r--test/files/specialized/SI-7343.scala55
-rw-r--r--test/files/specialized/SI-7344.scala53
-rw-r--r--test/files/specialized/spec-ame.check2
-rw-r--r--test/files/specialized/spec-ame.scala3
-rw-r--r--test/files/speclib/.gitignore1
54 files changed, 672 insertions, 459 deletions
diff --git a/test/files/codelib/.gitignore b/test/files/codelib/.gitignore
new file mode 100644
index 0000000000..f77a26afb7
--- /dev/null
+++ b/test/files/codelib/.gitignore
@@ -0,0 +1 @@
+code.jar
diff --git a/test/files/jvm/bytecode-test-example/Foo_1.flags b/test/files/jvm/bytecode-test-example/Foo_1.flags
new file mode 100644
index 0000000000..49f2d2c4c8
--- /dev/null
+++ b/test/files/jvm/bytecode-test-example/Foo_1.flags
@@ -0,0 +1 @@
+-Ybackend:GenASM
diff --git a/test/files/jvm/nooptimise/Foo_1.flags b/test/files/jvm/nooptimise/Foo_1.flags
index 9686c20775..f493cf9f3f 100644
--- a/test/files/jvm/nooptimise/Foo_1.flags
+++ b/test/files/jvm/nooptimise/Foo_1.flags
@@ -1 +1 @@
--optimise -Ynooptimise \ No newline at end of file
+-Ybackend:GenASM -optimise -Ynooptimise \ No newline at end of file
diff --git a/test/files/jvm/scala-concurrent-tck.check b/test/files/jvm/scala-concurrent-tck.check
deleted file mode 100644
index 18fc456acb..0000000000
--- a/test/files/jvm/scala-concurrent-tck.check
+++ /dev/null
@@ -1,3 +0,0 @@
-scala-concurrent-tck.scala:429: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses
- f
- ^
diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala
index 438ee310e6..6e2b8ca033 100644
--- a/test/files/jvm/scala-concurrent-tck.scala
+++ b/test/files/jvm/scala-concurrent-tck.scala
@@ -15,21 +15,17 @@ import scala.reflect.{ classTag, ClassTag }
import scala.tools.partest.TestUtil.intercept
trait TestBase {
-
- def once(body: (() => Unit) => Unit) {
- val sv = new SyncVar[Boolean]
- body(() => sv put true)
- sv.take(2000)
+ trait Done { def apply(proof: => Boolean): Unit }
+ def once(body: Done => Unit) {
+ import java.util.concurrent.{ LinkedBlockingQueue, TimeUnit }
+ val q = new LinkedBlockingQueue[Try[Boolean]]
+ body(new Done {
+ def apply(proof: => Boolean): Unit = q offer Try(proof)
+ })
+ assert(q.poll(2000, TimeUnit.MILLISECONDS).get)
+ // Check that we don't get more than one completion
+ assert(q.poll(50, TimeUnit.MILLISECONDS) eq null)
}
-
- // def assert(cond: => Boolean) {
- // try {
- // Predef.assert(cond)
- // } catch {
- // case e => e.printStackTrace()
- // }
- // }
-
}
@@ -39,99 +35,52 @@ trait FutureCallbacks extends TestBase {
def testOnSuccess(): Unit = once {
done =>
var x = 0
- val f = future {
- x = 1
- }
- f onSuccess {
- case _ =>
- done()
- assert(x == 1)
- }
+ val f = future { x = 1 }
+ f onSuccess { case _ => done(x == 1) }
}
def testOnSuccessWhenCompleted(): Unit = once {
done =>
var x = 0
- val f = future {
- x = 1
- }
+ val f = future { x = 1 }
f onSuccess {
- case _ =>
- assert(x == 1)
+ case _ if x == 1 =>
x = 2
- f onSuccess {
- case _ =>
- assert(x == 2)
- done()
- }
+ f onSuccess { case _ => done(x == 2) }
}
}
def testOnSuccessWhenFailed(): Unit = once {
done =>
- val f = future[Unit] {
- done()
- throw new Exception
- }
- f onSuccess {
- case _ => assert(false)
- }
+ val f = future[Unit] { throw new Exception }
+ f onSuccess { case _ => done(false) }
+ f onFailure { case _ => done(true) }
}
def testOnFailure(): Unit = once {
done =>
- var x = 0
- val f = future[Unit] {
- x = 1
- throw new Exception
- }
- f onSuccess {
- case _ =>
- done()
- assert(false)
- }
- f onFailure {
- case _ =>
- done()
- assert(x == 1)
- }
+ val f = future[Unit] { throw new Exception }
+ f onSuccess { case _ => done(false) }
+ f onFailure { case _ => done(true) }
}
def testOnFailureWhenSpecialThrowable(num: Int, cause: Throwable): Unit = once {
done =>
- val f = future[Unit] {
- throw cause
- }
- f onSuccess {
- case _ =>
- done()
- assert(false)
- }
+ val f = future[Unit] { throw cause }
+ f onSuccess { case _ => done(false) }
f onFailure {
- case e: ExecutionException if (e.getCause == cause) =>
- done()
- case _ =>
- done()
- assert(false)
+ case e: ExecutionException if e.getCause == cause => done(true)
+ case _ => done(false)
}
}
def testOnFailureWhenTimeoutException(): Unit = once {
done =>
- val f = future[Unit] {
- throw new TimeoutException()
- }
- f onSuccess {
- case _ =>
- done()
- assert(false)
- }
+ val f = future[Unit] { throw new TimeoutException() }
+ f onSuccess { case _ => done(false) }
f onFailure {
- case e: TimeoutException =>
- done()
- case other =>
- done()
- assert(false)
+ case e: TimeoutException => done(true)
+ case _ => done(false)
}
}
@@ -151,7 +100,6 @@ trait FutureCallbacks extends TestBase {
//testOnFailureWhenSpecialThrowable(7, new InterruptedException)
testThatNestedCallbacksDoNotYieldStackOverflow()
testOnFailureWhenTimeoutException()
-
}
@@ -162,207 +110,120 @@ trait FutureCombinators extends TestBase {
done =>
val f = future { 5 }
val g = f map { x => "result: " + x }
- g onSuccess {
- case s =>
- done()
- assert(s == "result: 5")
- }
- g onFailure {
- case _ =>
- done()
- assert(false)
- }
+ g onSuccess { case s => done(s == "result: 5") }
+ g onFailure { case _ => done(false) }
}
def testMapFailure(): Unit = once {
done =>
- val f = future {
- throw new Exception("exception message")
- }
+ val f = future[Unit] { throw new Exception("exception message") }
val g = f map { x => "result: " + x }
- g onSuccess {
- case _ =>
- done()
- assert(false)
- }
- g onFailure {
- case t =>
- done()
- assert(t.getMessage() == "exception message")
- }
+ g onSuccess { case _ => done(false) }
+ g onFailure { case t => done(t.getMessage() == "exception message") }
}
def testMapSuccessPF(): Unit = once {
done =>
val f = future { 5 }
val g = f map { case r => "result: " + r }
- g onSuccess {
- case s =>
- done()
- assert(s == "result: 5")
- }
- g onFailure {
- case _ =>
- done()
- assert(false)
- }
+ g onSuccess { case s => done(s == "result: 5") }
+ g onFailure { case _ => done(false) }
}
def testTransformSuccess(): Unit = once {
done =>
val f = future { 5 }
val g = f.transform(r => "result: " + r, identity)
- g onSuccess {
- case s =>
- done()
- assert(s == "result: 5")
- }
- g onFailure {
- case _ =>
- done()
- assert(false)
- }
+ g onSuccess { case s => done(s == "result: 5") }
+ g onFailure { case _ => done(false) }
}
def testTransformSuccessPF(): Unit = once {
done =>
val f = future { 5 }
val g = f.transform( { case r => "result: " + r }, identity)
- g onSuccess {
- case s =>
- done()
- assert(s == "result: 5")
- }
- g onFailure {
- case _ =>
- done()
- assert(false)
- }
+ g onSuccess { case s => done(s == "result: 5") }
+ g onFailure { case _ => done(false) }
+ }
+
+def testTransformFailure(): Unit = once {
+ done =>
+ val transformed = new Exception("transformed")
+ val f = future { throw new Exception("expected") }
+ val g = f.transform(identity, _ => transformed)
+ g onSuccess { case _ => done(false) }
+ g onFailure { case e => done(e eq transformed) }
+ }
+
+ def testTransformFailurePF(): Unit = once {
+ done =>
+ val e = new Exception("expected")
+ val transformed = new Exception("transformed")
+ val f = future[Unit] { throw e }
+ val g = f.transform(identity, { case `e` => transformed })
+ g onSuccess { case _ => done(false) }
+ g onFailure { case e => done(e eq transformed) }
}
def testFoldFailure(): Unit = once {
done =>
- val f = future {
- throw new Exception("exception message")
- }
+ val f = future[Unit] { throw new Exception("expected") }
val g = f.transform(r => "result: " + r, identity)
- g onSuccess {
- case _ =>
- done()
- assert(false)
- }
- g onFailure {
- case t =>
- done()
- assert(t.getMessage() == "exception message")
- }
+ g onSuccess { case _ => done(false) }
+ g onFailure { case t => done(t.getMessage() == "expected") }
}
def testFlatMapSuccess(): Unit = once {
done =>
val f = future { 5 }
val g = f flatMap { _ => future { 10 } }
- g onSuccess {
- case x =>
- done()
- assert(x == 10)
- }
- g onFailure {
- case _ =>
- done()
- assert(false)
- }
+ g onSuccess { case x => done(x == 10) }
+ g onFailure { case _ => done(false) }
}
def testFlatMapFailure(): Unit = once {
done =>
- val f = future {
- throw new Exception("exception message")
- }
+ val f = future[Unit] { throw new Exception("expected") }
val g = f flatMap { _ => future { 10 } }
- g onSuccess {
- case _ =>
- done()
- assert(false)
- }
- g onFailure {
- case t =>
- done()
- assert(t.getMessage() == "exception message")
- }
+ g onSuccess { case _ => done(false) }
+ g onFailure { case t => done(t.getMessage() == "expected") }
}
def testFilterSuccess(): Unit = once {
done =>
val f = future { 4 }
val g = f filter { _ % 2 == 0 }
- g onSuccess {
- case x: Int =>
- done()
- assert(x == 4)
- }
- g onFailure {
- case _ =>
- done()
- assert(false)
- }
+ g onSuccess { case x: Int => done(x == 4) }
+ g onFailure { case _ => done(false) }
}
def testFilterFailure(): Unit = once {
done =>
val f = future { 4 }
val g = f filter { _ % 2 == 1 }
- g onSuccess {
- case x: Int =>
- done()
- assert(false)
- }
+ g onSuccess { case x: Int => done(false) }
g onFailure {
- case e: NoSuchElementException =>
- done()
- assert(true)
- case _ =>
- done()
- assert(false)
+ case e: NoSuchElementException => done(true)
+ case _ => done(false)
}
}
def testCollectSuccess(): Unit = once {
done =>
val f = future { -5 }
- val g = f collect {
- case x if x < 0 => -x
- }
- g onSuccess {
- case x: Int =>
- done()
- assert(x == 5)
- }
- g onFailure {
- case _ =>
- done()
- assert(false)
- }
+ val g = f collect { case x if x < 0 => -x }
+ g onSuccess { case x: Int => done(x == 5) }
+ g onFailure { case _ => done(false) }
}
def testCollectFailure(): Unit = once {
done =>
val f = future { -5 }
- val g = f collect {
- case x if x > 0 => x * 2
- }
- g onSuccess {
- case _ =>
- done()
- assert(false)
- }
+ val g = f collect { case x if x > 0 => x * 2 }
+ g onSuccess { case _ => done(false) }
g onFailure {
- case e: NoSuchElementException =>
- done()
- assert(true)
- case _ =>
- done()
- assert(false)
+ case e: NoSuchElementException => done(true)
+ case _ => done(false)
}
}
@@ -376,16 +237,8 @@ trait FutureCombinators extends TestBase {
f foreach { x => p.success(x * 2) }
val g = p.future
- g.onSuccess {
- case res: Int =>
- done()
- assert(res == 10)
- }
- g.onFailure {
- case _ =>
- done()
- assert(false)
- }
+ g.onSuccess { case res: Int => done(res == 10) }
+ g.onFailure { case _ => done(false) }
}
def testForeachFailure(): Unit = once {
@@ -396,16 +249,8 @@ trait FutureCombinators extends TestBase {
f onFailure { case _ => p.failure(new Exception) }
val g = p.future
- g.onSuccess {
- case _ =>
- done()
- assert(false)
- }
- g.onFailure {
- case _ =>
- done()
- assert(true)
- }
+ g.onSuccess { case _ => done(false) }
+ g.onFailure { case _ => done(true) }
}
def testRecoverSuccess(): Unit = once {
@@ -415,18 +260,9 @@ trait FutureCombinators extends TestBase {
throw cause
} recover {
case re: RuntimeException =>
- "recovered"
- }
- f onSuccess {
- case x =>
- done()
- assert(x == "recovered")
- }
- f onFailure { case any =>
- done()
- assert(false)
- }
- f
+ "recovered" }
+ f onSuccess { case x => done(x == "recovered") }
+ f onFailure { case any => done(false) }
}
def testRecoverFailure(): Unit = once {
@@ -437,15 +273,8 @@ trait FutureCombinators extends TestBase {
} recover {
case te: TimeoutException => "timeout"
}
- f onSuccess {
- case x =>
- done()
- assert(false)
- }
- f onFailure { case any =>
- done()
- assert(any == cause)
- }
+ f onSuccess { case _ => done(false) }
+ f onFailure { case any => done(any == cause) }
}
def testRecoverWithSuccess(): Unit = once {
@@ -457,15 +286,8 @@ trait FutureCombinators extends TestBase {
case re: RuntimeException =>
future { "recovered" }
}
- f onSuccess {
- case x =>
- done()
- assert(x == "recovered")
- }
- f onFailure { case any =>
- done()
- assert(false)
- }
+ f onSuccess { case x => done(x == "recovered") }
+ f onFailure { case any => done(false) }
}
def testRecoverWithFailure(): Unit = once {
@@ -477,15 +299,8 @@ trait FutureCombinators extends TestBase {
case te: TimeoutException =>
future { "timeout" }
}
- f onSuccess {
- case x =>
- done()
- assert(false)
- }
- f onFailure { case any =>
- done()
- assert(any == cause)
- }
+ f onSuccess { case x => done(false) }
+ f onFailure { case any => done(any == cause) }
}
def testZipSuccess(): Unit = once {
@@ -493,52 +308,28 @@ trait FutureCombinators extends TestBase {
val f = future { 5 }
val g = future { 6 }
val h = f zip g
- h onSuccess {
- case (l: Int, r: Int) =>
- done()
- assert(l+r == 11)
- }
- h onFailure {
- case _ =>
- done()
- assert(false)
- }
+ h onSuccess { case (l: Int, r: Int) => done(l+r == 11) }
+ h onFailure { case _ => done(false) }
}
def testZipFailureLeft(): Unit = once {
done =>
- val cause = new Exception("exception message")
+ val cause = new Exception("expected")
val f = future { throw cause }
val g = future { 6 }
val h = f zip g
- h onSuccess {
- case _ =>
- done()
- assert(false)
- }
- h onFailure {
- case e: Exception =>
- done()
- assert(e.getMessage == "exception message")
- }
+ h onSuccess { case _ => done(false) }
+ h onFailure { case e: Exception => done(e.getMessage == "expected") }
}
def testZipFailureRight(): Unit = once {
done =>
- val cause = new Exception("exception message")
+ val cause = new Exception("expected")
val f = future { 5 }
val g = future { throw cause }
val h = f zip g
- h onSuccess {
- case _ =>
- done()
- assert(false)
- }
- h onFailure {
- case e: Exception =>
- done()
- assert(e.getMessage == "exception message")
- }
+ h onSuccess { case _ => done(false) }
+ h onFailure { case e: Exception => done(e.getMessage == "expected") }
}
def testFallbackTo(): Unit = once {
@@ -546,17 +337,8 @@ trait FutureCombinators extends TestBase {
val f = future { sys.error("failed") }
val g = future { 5 }
val h = f fallbackTo g
-
- h onSuccess {
- case x: Int =>
- done()
- assert(x == 5)
- }
- h onFailure {
- case _ =>
- done()
- assert(false)
- }
+ h onSuccess { case x: Int => done(x == 5) }
+ h onFailure { case _ => done(false) }
}
def testFallbackToFailure(): Unit = once {
@@ -566,16 +348,8 @@ trait FutureCombinators extends TestBase {
val g = future { throw cause }
val h = f fallbackTo g
- h onSuccess {
- case _ =>
- done()
- assert(false)
- }
- h onFailure {
- case e: Exception =>
- done()
- assert(e == cause)
- }
+ h onSuccess { case _ => done(false) }
+ h onFailure { case e => done(e eq cause) }
}
testMapSuccess()
@@ -597,6 +371,8 @@ trait FutureCombinators extends TestBase {
testZipFailureRight()
testFallbackTo()
testFallbackToFailure()
+ testTransformSuccess()
+ testTransformSuccessPF()
}
@@ -606,40 +382,26 @@ trait FutureProjections extends TestBase {
def testFailedFailureOnComplete(): Unit = once {
done =>
val cause = new RuntimeException
- val f = future {
- throw cause
- }
+ val f = future { throw cause }
f.failed onComplete {
- case Success(t) =>
- assert(t == cause)
- done()
- case Failure(t) =>
- assert(false)
+ case Success(t) => done(t == cause)
+ case Failure(t) => done(false)
}
}
def testFailedFailureOnSuccess(): Unit = once {
done =>
val cause = new RuntimeException
- val f = future {
- throw cause
- }
- f.failed onSuccess {
- case t =>
- assert(t == cause)
- done()
- }
+ val f = future { throw cause }
+ f.failed onSuccess { case t => done(t == cause) }
}
def testFailedSuccessOnComplete(): Unit = once {
done =>
val f = future { 0 }
f.failed onComplete {
- case Success(t) =>
- assert(false)
- case Failure(t) =>
- assert(t.isInstanceOf[NoSuchElementException])
- done()
+ case Failure(_: NoSuchElementException) => done(true)
+ case _ => done(false)
}
}
@@ -647,19 +409,17 @@ trait FutureProjections extends TestBase {
done =>
val f = future { 0 }
f.failed onFailure {
- case nsee: NoSuchElementException =>
- done()
+ case e: NoSuchElementException => done(true)
+ case _ => done(false)
}
+ f.failed onSuccess { case _ => done(false) }
}
def testFailedFailureAwait(): Unit = once {
done =>
val cause = new RuntimeException
- val f = future {
- throw cause
- }
- assert(Await.result(f.failed, Duration(500, "ms")) == cause)
- done()
+ val f = future { throw cause }
+ done(Await.result(f.failed, Duration(500, "ms")) == cause)
}
def testFailedSuccessAwait(): Unit = once {
@@ -667,9 +427,10 @@ trait FutureProjections extends TestBase {
val f = future { 0 }
try {
Await.result(f.failed, Duration(500, "ms"))
- assert(false)
+ done(false)
} catch {
- case nsee: NoSuchElementException => done()
+ case nsee: NoSuchElementException => done(true)
+ case _: Throwable => done(false)
}
}
@@ -682,8 +443,8 @@ trait FutureProjections extends TestBase {
Await.ready(f, Duration.Zero)
Await.ready(f, Duration(500, "ms"))
Await.ready(f, Duration.Inf)
- done()
- } onFailure { case x => throw x }
+ done(true)
+ } onFailure { case x => done(throw x) }
}
def testAwaitNegativeDuration(): Unit = once { done =>
@@ -692,8 +453,8 @@ trait FutureProjections extends TestBase {
intercept[TimeoutException] { Await.ready(f, Duration.Zero) }
intercept[TimeoutException] { Await.ready(f, Duration.MinusInf) }
intercept[TimeoutException] { Await.ready(f, Duration(-500, "ms")) }
- done()
- } onFailure { case x => throw x }
+ done(true)
+ } onFailure { case x => done(throw x) }
}
testFailedFailureOnComplete()
@@ -704,7 +465,6 @@ trait FutureProjections extends TestBase {
testFailedSuccessAwait()
testAwaitPositiveDuration()
testAwaitNegativeDuration()
-
}
@@ -714,33 +474,25 @@ trait Blocking extends TestBase {
def testAwaitSuccess(): Unit = once {
done =>
val f = future { 0 }
- Await.result(f, Duration(500, "ms"))
- done()
+ done(Await.result(f, Duration(500, "ms")) == 0)
}
def testAwaitFailure(): Unit = once {
done =>
val cause = new RuntimeException
- val f = future {
- throw cause
- }
+ val f = future { throw cause }
try {
Await.result(f, Duration(500, "ms"))
- assert(false)
+ done(false)
} catch {
- case t: Throwable =>
- assert(t == cause)
- done()
+ case t: Throwable => done(t == cause)
}
}
def testFQCNForAwaitAPI(): Unit = once {
done =>
-
- assert(classOf[CanAwait].getName == "scala.concurrent.CanAwait")
- assert(Await.getClass.getName == "scala.concurrent.Await")
-
- done()
+ done(classOf[CanAwait].getName == "scala.concurrent.CanAwait" &&
+ Await.getClass.getName == "scala.concurrent.Await")
}
testAwaitSuccess()
@@ -813,22 +565,26 @@ trait Promises extends TestBase {
val p = promise[Int]()
val f = p.future
- f onSuccess {
- case x =>
- done()
- assert(x == 5)
- }
- f onFailure {
- case any =>
- done()
- assert(false)
- }
+ f onSuccess { case x => done(x == 5) }
+ f onFailure { case any => done(false) }
p.success(5)
}
- testSuccess()
+ def testFailure(): Unit = once {
+ done =>
+ val e = new Exception("expected")
+ val p = promise[Int]()
+ val f = p.future
+
+ f onSuccess { case x => done(false) }
+ f onFailure { case any => done(any eq e) }
+
+ p.failure(e)
+ }
+ testSuccess()
+ testFailure()
}
@@ -888,11 +644,11 @@ trait CustomExecutionContext extends TestBase {
val count = countExecs { implicit ec =>
blocking {
once { done =>
- val f = future({ assertNoEC() })(defaultEC)
+ val f = future(assertNoEC())(defaultEC)
f onSuccess {
case _ =>
assertEC()
- done()
+ done(true)
}
assertNoEC()
}
@@ -911,7 +667,7 @@ trait CustomExecutionContext extends TestBase {
f onSuccess {
case _ =>
assertEC()
- done()
+ done(true)
}
}
}
@@ -935,15 +691,10 @@ trait CustomExecutionContext extends TestBase {
Promise.successful(x + 1).future.map(addOne).map(addOne)
} onComplete {
case Failure(t) =>
- try {
- throw new AssertionError("error in test: " + t.getMessage, t)
- } finally {
- done()
- }
+ done(throw new AssertionError("error in test: " + t.getMessage, t))
case Success(x) =>
assertEC()
- assert(x == 14)
- done()
+ done(x == 14)
}
assertNoEC()
}
@@ -999,21 +750,14 @@ trait ExecutionContextPrepare extends TestBase {
done =>
theLocal.set("secret")
val fut = future { 42 }
- fut onComplete {
- case _ =>
- assert(theLocal.get == "secret")
- done()
- }
+ fut onComplete { case _ => done(theLocal.get == "secret") }
}
def testMap(): Unit = once {
done =>
theLocal.set("secret2")
val fut = future { 42 }
- fut map { x =>
- assert(theLocal.get == "secret2")
- done()
- }
+ fut map { x => done(theLocal.get == "secret2") }
}
testOnComplete()
diff --git a/test/files/lib/.gitignore b/test/files/lib/.gitignore
new file mode 100644
index 0000000000..b4ac0b8789
--- /dev/null
+++ b/test/files/lib/.gitignore
@@ -0,0 +1,8 @@
+annotations.jar
+enums.jar
+genericNest.jar
+javac-artifacts.jar
+jsoup-1.3.1.jar
+methvsfield.jar
+nest.jar
+scalacheck.jar
diff --git a/test/files/neg/case-collision.flags b/test/files/neg/case-collision.flags
index 85d8eb2ba2..14c1069dee 100644
--- a/test/files/neg/case-collision.flags
+++ b/test/files/neg/case-collision.flags
@@ -1 +1 @@
--Xfatal-warnings
+-Ybackend:GenASM -Xfatal-warnings
diff --git a/test/files/neg/case-collision2.check b/test/files/neg/case-collision2.check
new file mode 100644
index 0000000000..b8481f46bb
--- /dev/null
+++ b/test/files/neg/case-collision2.check
@@ -0,0 +1,12 @@
+case-collision2.scala:5: warning: Class foo.BIPPY differs only in case from foo.Bippy. Such classes will overwrite one another on case-insensitive filesystems.
+class BIPPY
+ ^
+case-collision2.scala:8: warning: Class foo.DINGO$ differs only in case from foo.Dingo$. Such classes will overwrite one another on case-insensitive filesystems.
+object DINGO
+ ^
+case-collision2.scala:11: warning: Class foo.HyRaX$ differs only in case from foo.Hyrax$. Such classes will overwrite one another on case-insensitive filesystems.
+object HyRaX
+ ^
+error: No warnings can be incurred under -Xfatal-warnings.
+three warnings found
+one error found
diff --git a/test/files/neg/case-collision2.flags b/test/files/neg/case-collision2.flags
new file mode 100644
index 0000000000..5bfa9da5c5
--- /dev/null
+++ b/test/files/neg/case-collision2.flags
@@ -0,0 +1 @@
+-Ynooptimize -Ybackend:GenBCode -Xfatal-warnings
diff --git a/test/files/neg/case-collision2.scala b/test/files/neg/case-collision2.scala
new file mode 100644
index 0000000000..924e33005a
--- /dev/null
+++ b/test/files/neg/case-collision2.scala
@@ -0,0 +1,12 @@
+package foo
+
+class Bippy
+
+class BIPPY
+
+object Dingo
+object DINGO
+
+case class Hyrax()
+object HyRaX
+
diff --git a/test/files/neg/names-defaults-neg.check b/test/files/neg/names-defaults-neg.check
index f6bd703e1f..cdc12c2490 100644
--- a/test/files/neg/names-defaults-neg.check
+++ b/test/files/neg/names-defaults-neg.check
@@ -125,9 +125,12 @@ names-defaults-neg.scala:134: error: missing parameter type for expanded functio
names-defaults-neg.scala:135: error: parameter 'a' is already specified at parameter position 1
val taf3 = testAnnFun(b = _: String, a = get(8))
^
-names-defaults-neg.scala:136: error: wrong number of parameters; expected = 2
+names-defaults-neg.scala:136: error: missing parameter type for expanded function ((x$3) => testAnnFun(x$3, ((x$4) => b = x$4)))
val taf4: (Int, String) => Unit = testAnnFun(_, b = _)
- ^
+ ^
+names-defaults-neg.scala:136: error: missing parameter type for expanded function ((x$4) => b = x$4)
+ val taf4: (Int, String) => Unit = testAnnFun(_, b = _)
+ ^
names-defaults-neg.scala:144: error: variable definition needs type because 'x' is used as a named argument in its body.
def t3 { var x = t.f(x = 1) }
^
@@ -165,4 +168,4 @@ names-defaults-neg.scala:180: error: reference to x is ambiguous; it is both a m
class u18 { var x: Int = u.f(x = 1) }
^
four warnings found
-41 errors found
+42 errors found
diff --git a/test/files/neg/t1181.check b/test/files/neg/t1181.check
index 3724752a85..13b73d5381 100644
--- a/test/files/neg/t1181.check
+++ b/test/files/neg/t1181.check
@@ -1,8 +1,10 @@
t1181.scala:8: warning: a pure expression does nothing in statement position; you may be omitting necessary parentheses
case (Nil, Nil) => map
^
-t1181.scala:9: error: missing parameter type
+t1181.scala:9: error: type mismatch;
+ found : scala.collection.immutable.Map[Symbol,Symbol]
+ required: Symbol
_ => buildMap(map.updated(keyList.head, valueList.head), keyList.tail, valueList.tail)
- ^
+ ^
one warning found
one error found
diff --git a/test/files/neg/t556.check b/test/files/neg/t556.check
index c278e13991..5135dc92ef 100644
--- a/test/files/neg/t556.check
+++ b/test/files/neg/t556.check
@@ -1,4 +1,4 @@
-t556.scala:3: error: wrong number of parameters; expected = 1
+t556.scala:3: error: missing parameter type
def g:Int = f((x,y)=>x)
- ^
+ ^
one error found
diff --git a/test/files/neg/valueclasses-impl-restrictions.check b/test/files/neg/valueclasses-impl-restrictions.check
index 63924493aa..0af9173f74 100644
--- a/test/files/neg/valueclasses-impl-restrictions.check
+++ b/test/files/neg/valueclasses-impl-restrictions.check
@@ -6,12 +6,8 @@ valueclasses-impl-restrictions.scala:9: error: implementation restriction: neste
This restriction is planned to be removed in subsequent releases.
trait I2 {
^
-valueclasses-impl-restrictions.scala:15: error: implementation restriction: nested class is not allowed in value class
-This restriction is planned to be removed in subsequent releases.
- val i2 = new I2 { val q = x.s }
- ^
-valueclasses-impl-restrictions.scala:21: error: implementation restriction: nested class is not allowed in value class
+valueclasses-impl-restrictions.scala:23: error: implementation restriction: nested class is not allowed in value class
This restriction is planned to be removed in subsequent releases.
private[this] class I2(val q: String)
^
-four errors found
+three errors found
diff --git a/test/files/neg/valueclasses-impl-restrictions.scala b/test/files/neg/valueclasses-impl-restrictions.scala
index 137f3f854c..f0577a94aa 100644
--- a/test/files/neg/valueclasses-impl-restrictions.scala
+++ b/test/files/neg/valueclasses-impl-restrictions.scala
@@ -12,8 +12,10 @@ class X1(val s: String) extends AnyVal {
}
def y(x: X1) = {
- val i2 = new I2 { val q = x.s }
+ val i2 = new I2 { val q = x.s } // allowed as of SI-7571
i2.z
+
+ { case x => x } : PartialFunction[Int, Int] // allowed
}
}
diff --git a/test/files/pos/SI-7638.scala b/test/files/pos/SI-7638.scala
new file mode 100644
index 0000000000..da16e0bd2c
--- /dev/null
+++ b/test/files/pos/SI-7638.scala
@@ -0,0 +1,51 @@
+package miniboxing.tests.compile
+
+trait Ordering[@specialized(Int) A] {
+ def eqv(x: Array[A], y: Array[A]): Boolean = false
+}
+
+trait ArrayVectorOrder[@specialized(Int) A] extends Ordering[A] {
+ override def eqv(x: Array[A], y: Array[A]): Boolean = super.eqv(x, y)
+}
+
+object vectorOrder {
+ implicit def arrayOrder[@specialized(Int) A]() =
+ /*
+ * Before applying patch:
+ *
+ * while compiling: SI-7638.scala
+ * during phase: mixin
+ * library version: version 2.10.3-20130625-164027-d22e8d282c
+ * compiler version: version 2.10.3-20130627-153946-54cb6af7db
+ * reconstructed args:
+ *
+ * last tree to typer: TypeTree(class Array)
+ * symbol: class Array in package scala (flags: final)
+ * symbol definition: final class Array[T >: ? <: ?] extends Object
+ * tpe: Array[Int]
+ * symbol owners: class Array -> package scala
+ * context owners: anonymous class anon$1 -> package compile
+ *
+ * == Expanded type of tree ==
+ *
+ * TypeRef(
+ * TypeSymbol(final class Array[T >: ? <: ?] extends Object)
+ * args = List(TypeRef(TypeSymbol(final abstract class Int extends )))
+ * )
+ *
+ * unhandled exception while transforming SI-7638.scala
+ * error: uncaught exception during compilation: java.lang.UnsupportedOperationException
+ * error: java.lang.UnsupportedOperationException: tail of empty list
+ * at scala.collection.immutable.Nil$.tail(List.scala:339)
+ * at scala.collection.immutable.Nil$.tail(List.scala:334)
+ * at scala.tools.nsc.transform.Mixin$$anonfun$scala$tools$nsc$transform$Mixin$$rebindSuper$1.apply(Mixin.scala:123)
+ * at scala.tools.nsc.transform.Mixin$$anonfun$scala$tools$nsc$transform$Mixin$$rebindSuper$1.apply(Mixin.scala:122)
+ * at scala.reflect.internal.SymbolTable.atPhase(SymbolTable.scala:207)
+ * at scala.reflect.internal.SymbolTable.afterPhase(SymbolTable.scala:216)
+ * at scala.tools.nsc.Global.afterPickler(Global.scala:1104)
+ * at scala.tools.nsc.transform.Mixin.scala$tools$nsc$transform$Mixin$$rebindSuper(Mixin.scala:122)
+ * at scala.tools.nsc.transform.Mixin$$anonfun$scala$tools$nsc$transform$Mixin$$mixinTraitMembers$1$1.apply(Mixin.scala:339)
+ * at scala.tools.nsc.transform.Mixin$$anonfun$scala$tools$nsc$transform$Mixin$$mixinTraitMembers$1$1.apply(Mixin.scala:292)
+ */
+ new ArrayVectorOrder[A] { }
+}
diff --git a/test/files/pos/t3936/BlockingQueue.java b/test/files/pos/t3936/BlockingQueue.java
new file mode 100644
index 0000000000..b902d4528d
--- /dev/null
+++ b/test/files/pos/t3936/BlockingQueue.java
@@ -0,0 +1,3 @@
+package pack;
+import java.util.Queue;
+public interface BlockingQueue<E> extends Queue<E> { }
diff --git a/test/files/pos/t3936/Queue.java b/test/files/pos/t3936/Queue.java
new file mode 100644
index 0000000000..25c9087601
--- /dev/null
+++ b/test/files/pos/t3936/Queue.java
@@ -0,0 +1,2 @@
+package pack;
+public interface Queue { }
diff --git a/test/files/pos/t3936/Test.scala b/test/files/pos/t3936/Test.scala
new file mode 100644
index 0000000000..c867a05ec9
--- /dev/null
+++ b/test/files/pos/t3936/Test.scala
@@ -0,0 +1,4 @@
+package pack
+trait Test {
+ val b: BlockingQueue[Nothing]
+}
diff --git a/test/files/pos/t6221.scala b/test/files/pos/t6221.scala
new file mode 100644
index 0000000000..dd7776f596
--- /dev/null
+++ b/test/files/pos/t6221.scala
@@ -0,0 +1,29 @@
+class MyFunc[-A, +B] extends (A => B) { def apply(x: A): B = ??? }
+
+class MyCollection[A] {
+ def map[B](f: MyFunc[A, B]): MyCollection[B] = new MyCollection[B]
+}
+
+class OtherFunc[-A, +B] {}
+
+object Test {
+ implicit def functionToMyFunc[A, B](f: A => B): MyFunc[A, B] = new MyFunc
+
+ implicit def otherFuncToMyFunc[A, B](f: OtherFunc[A, B]): MyFunc[A, B] = new MyFunc
+
+ def main(args: Array[String]) {
+ val col = new MyCollection[Int]
+
+ // Doesn't compile: error: missing parameter type for expanded function ((x$1) => x$1.toString)
+ println(col.map(_.toString))
+
+ // Doesn't compile: error: missing parameter type
+ println(col.map(x => x.toString))
+
+ // Does compile
+ println(col.map((x: Int) => x.toString))
+
+ // Does compile (even though type params of OtherFunc not given)
+ println(col.map(new OtherFunc))
+ }
+} \ No newline at end of file
diff --git a/test/files/pos/t7591/Demo.scala b/test/files/pos/t7591/Demo.scala
new file mode 100644
index 0000000000..696d53585b
--- /dev/null
+++ b/test/files/pos/t7591/Demo.scala
@@ -0,0 +1,83 @@
+/* NEST (New Scala Test)
+ * Copyright 2007-2013 LAMP/EPFL
+ * @author Paul Phillips
+ */
+
+import scala.tools.cmd._
+
+/** A sample command specification for illustrative purposes.
+ * First take advantage of the meta-options:
+ *
+ * // this command creates an executable runner script "demo"
+ * % scala scala.tools.cmd.Demo --self-update demo
+ *
+ * // this one creates and sources a completion file - note backticks
+ * % `./demo --bash`
+ *
+ * // and now you have a runner with working completion
+ * % ./demo --<tab>
+ * --action --defint --int
+ * --bash --defstr --str
+ * --defenv --self-update --unary
+ *
+ * The normal option configuration is plausibly self-explanatory.
+ */
+trait DemoSpec extends Spec with Meta.StdOpts with Interpolation {
+ lazy val referenceSpec = DemoSpec
+ lazy val programInfo = Spec.Info("demo", "Usage: demo [<options>]", "scala.tools.cmd.Demo")
+
+ help("""Usage: demo [<options>]""")
+ heading("Unary options:")
+
+ val optIsUnary = "unary" / "a unary option" --? ;
+ ("action" / "a body which may be run") --> println("Hello, I am the --action body.")
+
+ heading("Binary options:")
+ val optopt = "str" / "an optional String" --|
+ val optoptInt = ("int" / "an optional Int") . --^[Int]
+ val optEnv = "defenv" / "an optional String" defaultToEnv "PATH"
+ val optDefault = "defstr" / "an optional String" defaultTo "default"
+ val optDefaultInt = "defint" / "an optional Int" defaultTo -1
+ val optExpand = "alias" / "an option which expands" expandTo ("--int", "15")
+}
+
+object DemoSpec extends DemoSpec with Property {
+ lazy val propMapper = new PropertyMapper(DemoSpec)
+
+ type ThisCommandLine = SpecCommandLine
+ def creator(args: List[String]) =
+ new SpecCommandLine(args) {
+ override def errorFn(msg: String) = { println("Error: " + msg) ; sys.exit(0) }
+ }
+}
+
+class Demo(args: List[String]) extends {
+ val parsed = DemoSpec(args: _*)
+} with DemoSpec with Instance {
+ import java.lang.reflect._
+
+ def helpMsg = DemoSpec.helpMsg
+ def demoSpecMethods = this.getClass.getMethods.toList
+ private def isDemo(m: Method) = (m.getName startsWith "opt") && !(m.getName contains "$") && (m.getParameterTypes.isEmpty)
+
+ def demoString(ms: List[Method]) = {
+ val longest = ms map (_.getName.length) max
+ val formatStr = " %-" + longest + "s: %s"
+ val xs = ms map (m => formatStr.format(m.getName, m.invoke(this)))
+
+ xs mkString ("Demo(\n ", "\n ", "\n)\n")
+ }
+
+ override def toString = demoString(demoSpecMethods filter isDemo)
+}
+
+object Demo {
+ def main(args: Array[String]): Unit = {
+ val runner = new Demo(args.toList)
+
+ if (args.isEmpty)
+ println(runner.helpMsg)
+
+ println(runner)
+ }
+}
diff --git a/test/files/run/stream_length.check b/test/files/run/stream_length.check
index 9906de773c..d1068f3247 100644
--- a/test/files/run/stream_length.check
+++ b/test/files/run/stream_length.check
@@ -1 +1,6 @@
+#partest !avian
Length: 970299
+
+#partest avian
+!!!TEST SKIPPED!!!
+See SI-7600 for further information.
diff --git a/test/files/run/stream_length.scala b/test/files/run/stream_length.scala
index 2808fbc495..33929f4b57 100644
--- a/test/files/run/stream_length.scala
+++ b/test/files/run/stream_length.scala
@@ -10,6 +10,10 @@ object Test {
}
def main(args: Array[String]) {
- println("Length: " + walk(3, "---").length)
+ if (scala.tools.partest.utils.Properties.isAvian) {
+ println("!!!TEST SKIPPED!!!")
+ println("See SI-7600 for further information.")
+ } else
+ println("Length: " + walk(3, "---").length)
}
}
diff --git a/test/files/run/t4294.scala b/test/files/run/t4294.scala
index fafaf1d8ef..e15c716047 100644
--- a/test/files/run/t4294.scala
+++ b/test/files/run/t4294.scala
@@ -1,7 +1,12 @@
object Test {
def main(args: Array[String]) {
+ // Skip test on Avian, see SI-7600 for further information
+ if (!scala.tools.partest.utils.Properties.isAvian)
+ run()
+ }
+
+ def run(): Unit = {
(Stream.from(1).collect{case x if x > 5000000 => x}: Stream[Int])
-
assert((Stream from 1 take 10 collect { case x if x <= 3 => x*x }).sum == 14)
}
}
diff --git a/test/files/run/t5603.scala b/test/files/run/t5603.scala
index 8c8038a602..77c2775cc3 100644
--- a/test/files/run/t5603.scala
+++ b/test/files/run/t5603.scala
@@ -1,7 +1,7 @@
import scala.tools.partest._
import java.io._
import scala.tools.nsc._
-import scala.tools.nsc.util.CommandLineParser
+import scala.tools.cmd.CommandLineParser
import scala.tools.nsc.{Global, Settings, CompilerCommand}
import scala.tools.nsc.reporters.ConsoleReporter
diff --git a/test/files/run/t6221.check b/test/files/run/t6221.check
new file mode 100644
index 0000000000..aa1bdd0e6e
--- /dev/null
+++ b/test/files/run/t6221.check
@@ -0,0 +1 @@
+((x) => x.$percent(2).$eq$eq(0))
diff --git a/test/files/run/t6221/Macros_1.scala b/test/files/run/t6221/Macros_1.scala
new file mode 100644
index 0000000000..c9500626d8
--- /dev/null
+++ b/test/files/run/t6221/Macros_1.scala
@@ -0,0 +1,22 @@
+import language.experimental.macros
+import language.implicitConversions
+import scala.reflect.macros.Context
+import scala.reflect.runtime.universe.Tree
+
+class ReflectiveClosure[A, B](val tree: Tree, fn: A => B) extends (A => B) {
+ def apply(x: A) = fn(x)
+}
+
+object ReflectiveClosure {
+ implicit def reflectClosure[A, B](f: A => B): ReflectiveClosure[A, B] = macro Macros.reflectiveClosureImpl[A, B]
+}
+
+object Macros {
+ def reflectiveClosureImpl[A, B](c: Context)(f: c.Expr[A => B]): c.Expr[ReflectiveClosure[A, B]] = {
+ import c.universe._
+ val u = treeBuild.mkRuntimeUniverseRef
+ val m = EmptyTree
+ val tree = c.Expr[scala.reflect.runtime.universe.Tree](Select(c.reifyTree(u, m, f.tree), newTermName("tree")))
+ c.universe.reify(new ReflectiveClosure(tree.splice, f.splice))
+ }
+}
diff --git a/test/files/run/t6221/Test_2.scala b/test/files/run/t6221/Test_2.scala
new file mode 100644
index 0000000000..9f6b2280a7
--- /dev/null
+++ b/test/files/run/t6221/Test_2.scala
@@ -0,0 +1,10 @@
+object Test extends App {
+ implicit class PimpedList[T](val list: List[T]) {
+ def query(predicate: ReflectiveClosure[T, Boolean]): List[T] = {
+ println(predicate.tree)
+ list filter predicate
+ }
+ }
+
+ List(1, 2, 3).query(x => x % 2 == 0)
+} \ No newline at end of file
diff --git a/test/files/run/t6308.scala b/test/files/run/t6308.scala
index bcd89359b0..d23cd6e13e 100644
--- a/test/files/run/t6308.scala
+++ b/test/files/run/t6308.scala
@@ -1,21 +1,25 @@
import scala.{specialized => sp}
+// NOTE: `{ val c = caller; print(""); c }` is used instead of a simple `caller`,
+// because we want to prevent tail-call optimization from eliding the stack-
+// frames we want to inspect.
+
object Test {
def caller = new Exception().getStackTrace()(1).getMethodName
- def f1[@sp(Int) A](a: A, b: Any) = caller
- def f2[@sp(Int) A, B](a: A, b: String) = caller
- def f3[B, @sp(Int) A](a: A, b: List[B]) = caller
- def f4[B, @sp(Int) A](a: A, b: List[(A, B)]) = caller
+ def f1[@sp(Int) A](a: A, b: Any) = { val c = caller; print(""); c }
+ def f2[@sp(Int) A, B](a: A, b: String) = { val c = caller; print(""); c }
+ def f3[B, @sp(Int) A](a: A, b: List[B]) = { val c = caller; print(""); c }
+ def f4[B, @sp(Int) A](a: A, b: List[(A, B)]) = { val c = caller; print(""); c }
- def f5[@sp(Int) A, B <: Object](a: A, b: B) = caller
+ def f5[@sp(Int) A, B <: Object](a: A, b: B) = { val c = caller; print(""); c }
// `uncurryTreeType` calls a TypeMap on the call to this method and we end up with new
// type parameter symbols, which are not found in `TypeEnv.includes(typeEnv(member), env)`
// in `specSym`. (One of `uncurry`'s tasks is to expand type aliases in signatures.)
type T = Object
- def todo1[@sp(Int) A, B <: T](a: A, b: String) = caller
- def todo2[@sp(Int) A, B <: AnyRef](a: A, b: String) = caller
- def todo3[B <: List[A], @specialized(Int) A](a: A, b: B) = caller
+ def todo1[@sp(Int) A, B <: T](a: A, b: String) = { val c = caller; print(""); c }
+ def todo2[@sp(Int) A, B <: AnyRef](a: A, b: String) = { val c = caller; print(""); c }
+ def todo3[B <: List[A], @specialized(Int) A](a: A, b: B) = { val c = caller; print(""); c }
def main(args: Array[String]) {
val s = ""
diff --git a/test/files/run/t6331.scala b/test/files/run/t6331.scala
index 4e43a7686e..d9d46f10ea 100644
--- a/test/files/run/t6331.scala
+++ b/test/files/run/t6331.scala
@@ -1,9 +1,4 @@
-import scala.tools.partest._
-import java.io._
-import scala.tools.nsc._
-import scala.tools.nsc.util.CommandLineParser
-import scala.tools.nsc.{Global, Settings, CompilerCommand}
-import scala.tools.nsc.reporters.ConsoleReporter
+import scala.tools.partest.DirectTest
// Test of Constant#equals, which must must account for floating point intricacies.
object Test extends DirectTest {
diff --git a/test/files/run/t6331b.scala b/test/files/run/t6331b.scala
index f966abea51..3e09965ee8 100644
--- a/test/files/run/t6331b.scala
+++ b/test/files/run/t6331b.scala
@@ -1,12 +1,5 @@
-import scala.tools.partest._
-import java.io._
-import scala.tools.nsc._
-import scala.tools.nsc.util.CommandLineParser
-import scala.tools.nsc.{Global, Settings, CompilerCommand}
-import scala.tools.nsc.reporters.ConsoleReporter
-
import scala.tools.partest.trace
-import scala.util.control.Exception._
+import scala.util.control.Exception.allCatch
object Test extends App {
diff --git a/test/files/run/t7008-scala-defined.flags b/test/files/run/t7008-scala-defined.flags
new file mode 100644
index 0000000000..49f2d2c4c8
--- /dev/null
+++ b/test/files/run/t7008-scala-defined.flags
@@ -0,0 +1 @@
+-Ybackend:GenASM
diff --git a/test/files/run/t7271.scala b/test/files/run/t7271.scala
index cb43331a29..69d5ea377e 100644
--- a/test/files/run/t7271.scala
+++ b/test/files/run/t7271.scala
@@ -1,7 +1,6 @@
import scala.tools.partest._
-import java.io._
import scala.tools.nsc._
-import scala.tools.nsc.util.CommandLineParser
+import scala.tools.cmd.CommandLineParser
import scala.tools.nsc.{Global, Settings, CompilerCommand}
import scala.tools.nsc.reporters.ConsoleReporter
import scala.reflect.internal.Positions
diff --git a/test/files/run/t7337.scala b/test/files/run/t7337.scala
index d878182ed0..9913f8ae45 100644
--- a/test/files/run/t7337.scala
+++ b/test/files/run/t7337.scala
@@ -1,6 +1,6 @@
import scala.tools.partest._
import scala.tools.nsc._
-import util.{CommandLineParser}
+import scala.tools.cmd.CommandLineParser
object Test extends DirectTest {
override def code = "class C"
diff --git a/test/files/run/t7439/Test_2.scala b/test/files/run/t7439/Test_2.scala
index 3ebbcfe753..ce9b907145 100644
--- a/test/files/run/t7439/Test_2.scala
+++ b/test/files/run/t7439/Test_2.scala
@@ -23,7 +23,8 @@ object Test extends StoreReporterDirectTest {
val a1Class = new File(testOutput.path, "A_1.class")
assert(a1Class.exists)
assert(a1Class.delete())
- println(s"Recompiling after deleting $a1Class")
+ // testIdent normalizes to separate names using '/' regardless of platform, drops all but last two parts
+ println(s"Recompiling after deleting ${a1Class.testIdent}")
// bad symbolic reference error expected (but no stack trace!)
compileCode(C)
diff --git a/test/files/run/t7571.scala b/test/files/run/t7571.scala
new file mode 100644
index 0000000000..00b9695168
--- /dev/null
+++ b/test/files/run/t7571.scala
@@ -0,0 +1,12 @@
+class Foo(val a: Int) extends AnyVal {
+ def foo = { {case x => x + a}: PartialFunction[Int, Int]}
+
+ def bar = (new {}).toString
+}
+
+object Test extends App {
+ val x = new Foo(1).foo.apply(2)
+ assert(x == 3, x)
+ val s = new Foo(1).bar
+ assert(s.nonEmpty, s)
+}
diff --git a/test/files/run/t7582-private-within.check b/test/files/run/t7582-private-within.check
new file mode 100644
index 0000000000..b2743ffa06
--- /dev/null
+++ b/test/files/run/t7582-private-within.check
@@ -0,0 +1,12 @@
+private[package pack] class JavaPackagePrivate
+private[package pack] module JavaPackagePrivate
+private[package pack] module class JavaPackagePrivate
+private[package pack] field field
+private[package pack] primary constructor <init>
+private[package pack] method meth
+private[package pack] field staticField
+private[package pack] method staticMeth
+private[package pack] method <clinit>
+private[package pack] field staticField
+private[package pack] method staticMeth
+private[package pack] method <clinit>
diff --git a/test/files/run/t7582-private-within/JavaPackagePrivate.java b/test/files/run/t7582-private-within/JavaPackagePrivate.java
new file mode 100644
index 0000000000..672d19b57e
--- /dev/null
+++ b/test/files/run/t7582-private-within/JavaPackagePrivate.java
@@ -0,0 +1,8 @@
+package pack;
+
+class JavaPackagePrivate {
+ int field = 0;
+ static int staticField = 0;
+ void meth() { }
+ static void staticMeth() { }
+}
diff --git a/test/files/run/t7582-private-within/Test.scala b/test/files/run/t7582-private-within/Test.scala
new file mode 100644
index 0000000000..3d581f063b
--- /dev/null
+++ b/test/files/run/t7582-private-within/Test.scala
@@ -0,0 +1,22 @@
+import scala.tools.partest.DirectTest
+
+// Testing that the `privateWithin` field is correctly populated on all
+// the related symbols (e.g. module class) under separate compilation.
+object Test extends DirectTest {
+ def code = ???
+
+ def show(): Unit = {
+ val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator")
+ val global = newCompiler("-usejavacp", "-cp", classpath, "-d", testOutput.path)
+ import global._
+ withRun(global) { _ =>
+ def check(sym: Symbol) = {
+ sym.initialize
+ println(f"${sym.accessString}%12s ${sym.accurateKindString} ${sym.name.decode}") // we want to see private[pack] for all of these.
+ }
+ val sym = rootMirror.getRequiredClass("pack.JavaPackagePrivate")
+ val syms = Seq(sym, sym.companionModule, sym.companionModule.moduleClass)
+ (syms ++ syms.flatMap(_.info.decls)).foreach(check)
+ }
+ }
+}
diff --git a/test/files/run/t7582.check b/test/files/run/t7582.check
new file mode 100644
index 0000000000..225fb1ace8
--- /dev/null
+++ b/test/files/run/t7582.check
@@ -0,0 +1,2 @@
+warning: there were 1 inliner warning(s); re-run with -Yinline-warnings for details
+2
diff --git a/test/files/run/t7582.flags b/test/files/run/t7582.flags
new file mode 100644
index 0000000000..1182725e86
--- /dev/null
+++ b/test/files/run/t7582.flags
@@ -0,0 +1 @@
+-optimize \ No newline at end of file
diff --git a/test/files/run/t7582/InlineHolder.scala b/test/files/run/t7582/InlineHolder.scala
new file mode 100644
index 0000000000..a18b9effaa
--- /dev/null
+++ b/test/files/run/t7582/InlineHolder.scala
@@ -0,0 +1,16 @@
+package p1 {
+ object InlineHolder {
+ @inline def inlinable = p1.PackageProtectedJava.protectedMethod() + 1
+ }
+}
+
+object O {
+ @noinline
+ def x = p1.InlineHolder.inlinable
+}
+
+object Test {
+ def main(args: Array[String]) {
+ println(O.x)
+ }
+}
diff --git a/test/files/run/t7582/PackageProtectedJava.java b/test/files/run/t7582/PackageProtectedJava.java
new file mode 100644
index 0000000000..b7ea2a7676
--- /dev/null
+++ b/test/files/run/t7582/PackageProtectedJava.java
@@ -0,0 +1,6 @@
+package p1;
+
+// public class, protected method
+public class PackageProtectedJava {
+ static final int protectedMethod() { return 1; }
+}
diff --git a/test/files/run/t7582b.check b/test/files/run/t7582b.check
new file mode 100644
index 0000000000..225fb1ace8
--- /dev/null
+++ b/test/files/run/t7582b.check
@@ -0,0 +1,2 @@
+warning: there were 1 inliner warning(s); re-run with -Yinline-warnings for details
+2
diff --git a/test/files/run/t7582b.flags b/test/files/run/t7582b.flags
new file mode 100644
index 0000000000..1182725e86
--- /dev/null
+++ b/test/files/run/t7582b.flags
@@ -0,0 +1 @@
+-optimize \ No newline at end of file
diff --git a/test/files/run/t7582b/InlineHolder.scala b/test/files/run/t7582b/InlineHolder.scala
new file mode 100644
index 0000000000..a18b9effaa
--- /dev/null
+++ b/test/files/run/t7582b/InlineHolder.scala
@@ -0,0 +1,16 @@
+package p1 {
+ object InlineHolder {
+ @inline def inlinable = p1.PackageProtectedJava.protectedMethod() + 1
+ }
+}
+
+object O {
+ @noinline
+ def x = p1.InlineHolder.inlinable
+}
+
+object Test {
+ def main(args: Array[String]) {
+ println(O.x)
+ }
+}
diff --git a/test/files/run/t7582b/PackageProtectedJava.java b/test/files/run/t7582b/PackageProtectedJava.java
new file mode 100644
index 0000000000..55a44b79f9
--- /dev/null
+++ b/test/files/run/t7582b/PackageProtectedJava.java
@@ -0,0 +1,6 @@
+package p1;
+
+// protected class, public method
+class PackageProtectedJava {
+ public static final int protectedMethod() { return 1; }
+}
diff --git a/test/files/scalacheck/si4147.scala b/test/files/scalacheck/si4147.scala
index 1453440ef1..05507b1b18 100644
--- a/test/files/scalacheck/si4147.scala
+++ b/test/files/scalacheck/si4147.scala
@@ -1,4 +1,4 @@
-import org.scalacheck.Prop.forAll
+import org.scalacheck.Prop.{forAll, throws}
import org.scalacheck.Properties
import org.scalacheck.ConsoleReporter.testStatsEx
import org.scalacheck.Gen
@@ -64,4 +64,7 @@ object Test extends Properties("Mutable TreeSet") {
view.filter(_ < 50) == Set[Int]() && view.filter(_ >= 150) == Set[Int]()
}
}
+
+ property("ordering must not be null") =
+ throws(mutable.TreeSet.empty[Int](null), classOf[NullPointerException])
}
diff --git a/test/files/scalacheck/treeset.scala b/test/files/scalacheck/treeset.scala
index 98e38c8219..018c1b9e29 100644
--- a/test/files/scalacheck/treeset.scala
+++ b/test/files/scalacheck/treeset.scala
@@ -149,4 +149,7 @@ object Test extends Properties("TreeSet") {
val result = subject.foldLeft(subject)((acc, elt) => acc - elt)
result.isEmpty
}
+
+ property("ordering must not be null") =
+ throws(TreeSet.empty[Int](null), classOf[NullPointerException])
}
diff --git a/test/files/specialized/SI-7343.scala b/test/files/specialized/SI-7343.scala
new file mode 100644
index 0000000000..5ee683064c
--- /dev/null
+++ b/test/files/specialized/SI-7343.scala
@@ -0,0 +1,55 @@
+class Parent[@specialized(Int) T]
+
+object Test extends App {
+
+ /**
+ * This method will check if specialization is correctly rewiring parents
+ * for classes defined inside methods. The pattern is important since this
+ * is how closures are currently represented: as locally-defined anonymous
+ * classes, which usually end up inside methods. For these closures we do
+ * want their parents rewired correctly:
+ *
+ * ```
+ * def checkSuperClass$mIc$sp[T](t: T, ...) = {
+ * class X extends Parent$mcI$sp // instead of just Parent
+ * ...
+ * }
+ */
+ def checkSuperClass[@specialized(Int) T](t: T, expectedXSuper: String) = {
+ // test target:
+ // - in checkSuperClass, X should extend Parent
+ // - in checkSuperClass$mIc$sp, X should extend Parent$mcI$sp
+ class X extends Parent[T]()
+
+ // get the superclass for X and make sure it's correct
+ val actualXSuper = (new X).getClass().getSuperclass().getSimpleName()
+ assert(actualXSuper == expectedXSuper, actualXSuper + " != " + expectedXSuper)
+ }
+
+ checkSuperClass("x", "Parent")
+ checkSuperClass(101, "Parent$mcI$sp")
+
+ /**
+ * This is the same check, but in value. It should work exactly the same
+ * as its method counterpart.
+ */
+ class Val[@specialized(Int) T](t: T, expectedXSuper: String) {
+ val check: T = {
+ class X extends Parent[T]()
+
+ // get the superclass for X and make sure it's correct
+ val actualXSuper = (new X).getClass().getSuperclass().getSimpleName()
+ assert(actualXSuper == expectedXSuper, actualXSuper + " != " + expectedXSuper)
+ t
+ }
+ }
+
+ new Val("x", "Parent")
+ new Val(101, "Parent$mcI$sp")
+
+ /**
+ * NOTE: The the same check, only modified to affect constructors, won't
+ * work since the class X definition will always be lifted to become a
+ * member of the class, making it impossible to force its duplication.
+ */
+}
diff --git a/test/files/specialized/SI-7344.scala b/test/files/specialized/SI-7344.scala
new file mode 100644
index 0000000000..1040460bd1
--- /dev/null
+++ b/test/files/specialized/SI-7344.scala
@@ -0,0 +1,53 @@
+/* Test for SI-7344, where specialized methods inside the bodies of other
+ * methods are not specialized, although they might as well be. The name
+ * for the specialized method should not be different depending on the
+ * outside method/class' specialization. */
+
+class Test[@specialized(Int, Double) X](val x: X) {
+
+ def checkSpecialization[Y](@specialized(Int, Double) y: Y): X = {
+
+ // checking the specialization using the method name, which we can
+ // extract from an exception's stack trace. We can match just the
+ // prefix, since the compiler will add a suffix to the method name
+ // during lambdalift, when it lifts the local methods outside.
+ def specMe[@specialized(Int, Double) T, N](t: T, n: N): Unit = checkNameStartsWith(n.toString)
+
+ // expected to specialize:
+ specMe("x", "specMe")
+ specMe(123, "specMe$mIc$sp")
+ specMe(1.3, new { override def toString = "specMe$mDc$sp" })
+
+ x
+ }
+
+ // name matching:
+ private[this] def checkNameStartsWith(prefix: String): Unit = {
+ val method = (new Exception).getStackTrace()(1).getMethodName()
+ assert(method.startsWith(prefix), method + ".startsWith(" + prefix + ") should be true")
+ }
+}
+
+object Test extends App {
+ val t1 = new Test("x")
+ val t2 = new Test(123)
+ val t3 = new Test(1.3)
+
+ // we want specialization to rewire these,
+ // that's why they're not in a for loop:
+ t1.checkSpecialization("x")
+
+ // Prevented by SI-7579:
+ // The duplicator loses the @specialized annotation,
+ // so our tree transformation doesn't know it needs to
+ // specialize specMe inside the duplicated (and specialized)
+ // variants of the `checkSpecialization` method
+ // t1.checkSpecialization(123)
+ // t1.checkSpecialization(1.3)
+ // t2.checkSpecialization("x")
+ // t2.checkSpecialization(123)
+ // t2.checkSpecialization(1.3)
+ // t3.checkSpecialization("x")
+ // t3.checkSpecialization(123)
+ // t3.checkSpecialization(1.3)
+}
diff --git a/test/files/specialized/spec-ame.check b/test/files/specialized/spec-ame.check
index 9c1713cc8a..cf18c01191 100644
--- a/test/files/specialized/spec-ame.check
+++ b/test/files/specialized/spec-ame.check
@@ -1,3 +1,3 @@
abc
10
-3 \ No newline at end of file
+2
diff --git a/test/files/specialized/spec-ame.scala b/test/files/specialized/spec-ame.scala
index 79ee4217ed..129fb9f447 100644
--- a/test/files/specialized/spec-ame.scala
+++ b/test/files/specialized/spec-ame.scala
@@ -13,6 +13,9 @@ object Test {
def main(args: Array[String]) {
println((new A("abc")).foo.value)
println((new A(10)).foo.value)
+ // before fixing SI-7343, this was printing 3. Now it's printing 2,
+ // since the anonymous class created by doing new B[T] { ... } when
+ // T = Int is now rewired to B$mcI$sp instead of just B[Int]
println(runtime.BoxesRunTime.integerBoxCount)
}
}
diff --git a/test/files/speclib/.gitignore b/test/files/speclib/.gitignore
new file mode 100644
index 0000000000..2b26f5dfc5
--- /dev/null
+++ b/test/files/speclib/.gitignore
@@ -0,0 +1 @@
+instrumented.jar