summaryrefslogtreecommitdiff
path: root/test/files/jvm
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/jvm')
-rw-r--r--test/files/jvm/actor-exceptions.scala4
-rw-r--r--test/files/jvm/actor-executor.scala5
-rw-r--r--test/files/jvm/actor-executor2.scala6
-rw-r--r--test/files/jvm/actor-executor3.scala6
-rw-r--r--test/files/jvm/actor-getstate.scala6
-rw-r--r--test/files/jvm/actor-link-getstate.scala9
-rw-r--r--test/files/jvm/actor-looping.scala3
-rw-r--r--test/files/jvm/actor-normal-exit.scala4
-rw-r--r--test/files/jvm/actor-receivewithin.scala5
-rw-r--r--test/files/jvm/actor-sync-send-timeout.scala7
-rw-r--r--test/files/jvm/actor-termination.scala3
-rw-r--r--test/files/jvm/actor-uncaught-exception.scala55
-rw-r--r--test/files/jvm/actor-uncaught-exception2.check4
-rw-r--r--test/files/jvm/actor-uncaught-exception2.scala56
-rw-r--r--test/files/jvm/annotations.scala3
-rw-r--r--test/files/jvm/backendBugUnapply.check2
-rw-r--r--test/files/jvm/backendBugUnapply.scala17
-rw-r--r--test/files/jvm/bytecode-test-example/Foo_1.flags1
-rw-r--r--test/files/jvm/console.scala2
-rw-r--r--test/files/jvm/constant-optimization/Foo_1.flags1
-rw-r--r--test/files/jvm/constant-optimization/Foo_1.scala9
-rw-r--r--test/files/jvm/constant-optimization/Test.scala27
-rw-r--r--test/files/jvm/daemon-actor-termination.scala4
-rw-r--r--test/files/jvm/deprecation.check3
-rw-r--r--test/files/jvm/deprecation/Test_1.scala2
-rw-r--r--test/files/jvm/duration-tck.scala2
-rw-r--r--test/files/jvm/future-alarm.scala4
-rw-r--r--test/files/jvm/future-awaitall-zero.scala6
-rw-r--r--test/files/jvm/future-spec.check1
-rw-r--r--test/files/jvm/future-spec/FutureTests.scala226
-rw-r--r--test/files/jvm/future-spec/PromiseTests.scala80
-rw-r--r--test/files/jvm/future-spec/TryTests.scala2
-rw-r--r--test/files/jvm/future-spec/main.scala52
-rw-r--r--test/files/jvm/future-termination.scala28
-rw-r--r--test/files/jvm/inner.scala2
-rw-r--r--test/files/jvm/interpreter.check14
-rw-r--r--test/files/jvm/interpreter.scala2
-rw-r--r--test/files/jvm/manifests-new.check4
-rw-r--r--test/files/jvm/manifests-new.scala34
-rw-r--r--test/files/jvm/manifests-old.scala34
-rw-r--r--test/files/jvm/methvsfield.java6
-rw-r--r--test/files/jvm/named-args-in-order.check3
-rw-r--r--test/files/jvm/named-args-in-order/SameBytecode.scala9
-rw-r--r--test/files/jvm/named-args-in-order/Test.scala10
-rw-r--r--test/files/jvm/natives.scala6
-rw-r--r--test/files/jvm/non-fatal-tests.scala12
-rw-r--r--test/files/jvm/nooptimise/Foo_1.flags1
-rw-r--r--test/files/jvm/nooptimise/Foo_1.scala8
-rw-r--r--test/files/jvm/nooptimise/Test.scala23
-rw-r--r--test/files/jvm/opt_value_class.check2
-rw-r--r--test/files/jvm/opt_value_class/Value_1.scala28
-rw-r--r--test/files/jvm/opt_value_class/test.scala16
-rw-r--r--test/files/jvm/patmat_opt_ignore_underscore/Analyzed_1.scala2
-rw-r--r--test/files/jvm/patmat_opt_no_nullcheck/Analyzed_1.scala2
-rw-r--r--test/files/jvm/patmat_opt_primitive_typetest/Analyzed_1.scala2
-rw-r--r--test/files/jvm/protectedacc.scala16
-rw-r--r--test/files/jvm/reactor-exceptionOnSend.scala5
-rw-r--r--test/files/jvm/reactor-producer-consumer.scala4
-rw-r--r--test/files/jvm/reactor.scala16
-rw-r--r--test/files/jvm/replyablereactor.scala5
-rw-r--r--test/files/jvm/replyablereactor2.scala5
-rw-r--r--test/files/jvm/replyablereactor3.scala5
-rw-r--r--test/files/jvm/replyablereactor4.scala5
-rw-r--r--test/files/jvm/replyreactor-react-sender.scala6
-rw-r--r--test/files/jvm/replyreactor.scala4
-rw-r--r--test/files/jvm/scala-concurrent-tck.scala178
-rw-r--r--test/files/jvm/scheduler-adapter.scala5
-rw-r--r--test/files/jvm/serialization-new.check55
-rw-r--r--test/files/jvm/serialization-new.scala67
-rw-r--r--test/files/jvm/serialization.check55
-rw-r--r--test/files/jvm/serialization.scala116
-rw-r--r--test/files/jvm/si5471.scala4
-rw-r--r--test/files/jvm/stringbuilder.scala1
-rwxr-xr-xtest/files/jvm/t0632.check12
-rw-r--r--test/files/jvm/t0632.scala22
-rw-r--r--test/files/jvm/t1116.check0
-rwxr-xr-xtest/files/jvm/t1118.check11
-rwxr-xr-xtest/files/jvm/t1118.scala21
-rw-r--r--test/files/jvm/t1143-2/t1143-2.scala26
-rw-r--r--test/files/jvm/t1143.check0
-rw-r--r--test/files/jvm/t1143.scala12
-rw-r--r--test/files/jvm/t1342/SI.scala2
-rw-r--r--test/files/jvm/t1449.scala9
-rw-r--r--test/files/jvm/t1461.scala2
-rw-r--r--test/files/jvm/t1464/MyTrait.scala2
-rw-r--r--test/files/jvm/t1600.scala27
-rw-r--r--test/files/jvm/t1948.check0
-rw-r--r--test/files/jvm/t1948.scala6
-rw-r--r--test/files/jvm/t2104.check0
-rw-r--r--test/files/jvm/t2163/t2163.java (renamed from test/files/jvm/ticket2163/ticket2163.java)4
-rw-r--r--test/files/jvm/t2163/t2163.scala10
-rw-r--r--test/files/jvm/t2359.scala4
-rw-r--r--test/files/jvm/t2470.cmds3
-rw-r--r--test/files/jvm/t2530.scala6
-rw-r--r--test/files/jvm/t2570.check0
-rw-r--r--test/files/jvm/t2570/Test.scala2
-rw-r--r--test/files/jvm/t2585.check0
-rw-r--r--test/files/jvm/t3003.cmds2
-rw-r--r--test/files/jvm/t3003/Test_1.scala2
-rw-r--r--test/files/jvm/t3102.scala7
-rw-r--r--test/files/jvm/t3356.scala5
-rw-r--r--test/files/jvm/t3365.scala5
-rw-r--r--test/files/jvm/t3407.scala4
-rw-r--r--test/files/jvm/t3412-channel.scala4
-rw-r--r--test/files/jvm/t3412.scala4
-rw-r--r--test/files/jvm/t3415/HelloWorld.scala2
-rw-r--r--test/files/jvm/t3470.scala4
-rw-r--r--test/files/jvm/t3838.scala4
-rw-r--r--test/files/jvm/t4283/AbstractFoo.java (renamed from test/files/jvm/ticket4283/AbstractFoo.java)0
-rw-r--r--test/files/jvm/t4283/ScalaBipp.scala (renamed from test/files/jvm/ticket4283/ScalaBipp.scala)0
-rw-r--r--test/files/jvm/t4283/Test.scala (renamed from test/files/jvm/ticket4283/Test.scala)0
-rw-r--r--test/files/jvm/t560bis.check2
-rw-r--r--test/files/jvm/t560bis.scala21
-rw-r--r--test/files/jvm/t680.check0
-rw-r--r--test/files/jvm/t6941/Analyzed_1.flags1
-rw-r--r--test/files/jvm/t7006.check29
-rw-r--r--test/files/jvm/t7006/Foo_1.flags1
-rw-r--r--test/files/jvm/t7006/Foo_1.scala10
-rw-r--r--test/files/jvm/t7006/Test.scala19
-rw-r--r--test/files/jvm/t7146.scala2
-rw-r--r--test/files/jvm/t7181/Foo_1.scala26
-rw-r--r--test/files/jvm/t7181/Test.scala24
-rw-r--r--test/files/jvm/throws-annot.scala10
-rw-r--r--test/files/jvm/ticket2163/ticket2163.scala5
-rw-r--r--test/files/jvm/try-type-tests.scala3
-rw-r--r--test/files/jvm/typerep.scala30
-rw-r--r--test/files/jvm/unittest_io_Jvm.check2
-rw-r--r--test/files/jvm/unittest_io_Jvm.scala2
-rw-r--r--test/files/jvm/unittest_xml.scala101
-rw-r--r--test/files/jvm/unreachable/Foo_1.flags1
-rw-r--r--test/files/jvm/unreachable/Foo_1.scala112
-rw-r--r--test/files/jvm/unreachable/Test.scala23
-rw-r--r--test/files/jvm/value-class-boxing.check7
-rw-r--r--test/files/jvm/value-class-boxing/Analyzed_1.scala17
-rw-r--r--test/files/jvm/value-class-boxing/test.scala15
-rw-r--r--test/files/jvm/varargs/JavaClass.java2
-rw-r--r--test/files/jvm/varargs/VaClass.scala4
-rwxr-xr-xtest/files/jvm/xml01.check8
-rw-r--r--test/files/jvm/xml01.scala181
-rw-r--r--test/files/jvm/xml02.check0
-rw-r--r--test/files/jvm/xml02.scala78
-rwxr-xr-xtest/files/jvm/xml03syntax.check26
-rw-r--r--test/files/jvm/xml03syntax.scala97
-rw-r--r--test/files/jvm/xml04embed.check3
-rw-r--r--test/files/jvm/xml04embed.scala10
-rw-r--r--test/files/jvm/xml05.check4
-rw-r--r--test/files/jvm/xmlattr.check18
-rw-r--r--test/files/jvm/xmlattr.scala63
-rw-r--r--test/files/jvm/xmlmore.check10
-rw-r--r--test/files/jvm/xmlmore.scala29
-rw-r--r--test/files/jvm/xmlpull.scala31
-rw-r--r--test/files/jvm/xmlstuff.check22
-rw-r--r--test/files/jvm/xmlstuff.scala181
153 files changed, 1118 insertions, 1753 deletions
diff --git a/test/files/jvm/actor-exceptions.scala b/test/files/jvm/actor-exceptions.scala
index 3ee4db9ed2..bdd983a0e8 100644
--- a/test/files/jvm/actor-exceptions.scala
+++ b/test/files/jvm/actor-exceptions.scala
@@ -1,4 +1,7 @@
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.{Actor, Exit}
import Actor._
@@ -58,7 +61,6 @@ object Slave extends Actor {
case object A
-object Test {
def main(args: Array[String]) {
Master.start()
}
diff --git a/test/files/jvm/actor-executor.scala b/test/files/jvm/actor-executor.scala
index b1f9caebdd..0fc28b4d85 100644
--- a/test/files/jvm/actor-executor.scala
+++ b/test/files/jvm/actor-executor.scala
@@ -1,3 +1,7 @@
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import java.util.concurrent.Executors
import scala.actors.{Actor, SchedulerAdapter}
import Actor._
@@ -50,7 +54,6 @@ object Two extends AdaptedActor {
}
}
-object Test {
val executor =
Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors())
diff --git a/test/files/jvm/actor-executor2.scala b/test/files/jvm/actor-executor2.scala
index f8fcaef69f..5badf2ae7e 100644
--- a/test/files/jvm/actor-executor2.scala
+++ b/test/files/jvm/actor-executor2.scala
@@ -1,3 +1,8 @@
+
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.{Actor, SchedulerAdapter, Exit}
import Actor._
import java.util.concurrent.{Executors, RejectedExecutionException}
@@ -48,7 +53,6 @@ trait AdaptedActor extends Actor {
Test.scheduler
}
-object Test {
val NUM_MSG = 100000
val executor =
diff --git a/test/files/jvm/actor-executor3.scala b/test/files/jvm/actor-executor3.scala
index 4fde2c6c5f..f8b57d84b3 100644
--- a/test/files/jvm/actor-executor3.scala
+++ b/test/files/jvm/actor-executor3.scala
@@ -1,3 +1,8 @@
+
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.Actor
import scala.actors.scheduler.ExecutorScheduler
import java.util.concurrent.Executors
@@ -48,7 +53,6 @@ trait AdaptedActor extends Actor {
Test.scheduler
}
-object Test {
val NUM_MSG = 100000
val executor =
diff --git a/test/files/jvm/actor-getstate.scala b/test/files/jvm/actor-getstate.scala
index a6e15a8721..425efbe5e6 100644
--- a/test/files/jvm/actor-getstate.scala
+++ b/test/files/jvm/actor-getstate.scala
@@ -1,7 +1,9 @@
-import scala.actors.{Reactor, Actor, TIMEOUT}
-import Actor._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.{Reactor, Actor, TIMEOUT}
+ import Actor._
def assert(cond: => Boolean, hint: String) {
if (!cond)
diff --git a/test/files/jvm/actor-link-getstate.scala b/test/files/jvm/actor-link-getstate.scala
index c24daf2eff..d8b8ada1e6 100644
--- a/test/files/jvm/actor-link-getstate.scala
+++ b/test/files/jvm/actor-link-getstate.scala
@@ -1,5 +1,9 @@
-import scala.actors.{Actor, Exit}
-import scala.actors.Actor._
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
+ import scala.actors.{Actor, Exit}
+ import scala.actors.Actor._
case class MyException(text: String) extends Exception(text) {
override def fillInStackTrace() = this
@@ -39,7 +43,6 @@ object Master extends Actor {
}
}
-object Test {
def main(args: Array[String]) {
actor {
diff --git a/test/files/jvm/actor-looping.scala b/test/files/jvm/actor-looping.scala
index 475d4754ce..7bc6f1e5c5 100644
--- a/test/files/jvm/actor-looping.scala
+++ b/test/files/jvm/actor-looping.scala
@@ -1,7 +1,8 @@
-import scala.actors.Actor._
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.Actor._
case object A
def main(args: Array[String]) {
diff --git a/test/files/jvm/actor-normal-exit.scala b/test/files/jvm/actor-normal-exit.scala
index 20863d5bb0..90495866e2 100644
--- a/test/files/jvm/actor-normal-exit.scala
+++ b/test/files/jvm/actor-normal-exit.scala
@@ -1,7 +1,9 @@
-import scala.actors.{Actor, Exit}
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.{Actor, Exit}
object Master extends Actor {
trapExit = true
def act() {
diff --git a/test/files/jvm/actor-receivewithin.scala b/test/files/jvm/actor-receivewithin.scala
index a5c87c2722..5982462502 100644
--- a/test/files/jvm/actor-receivewithin.scala
+++ b/test/files/jvm/actor-receivewithin.scala
@@ -1,3 +1,7 @@
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.{Actor, TIMEOUT}
object A extends Actor {
@@ -62,7 +66,6 @@ object B extends Actor {
}
}
-object Test {
def main(args:Array[String]) {
B.start()
}
diff --git a/test/files/jvm/actor-sync-send-timeout.scala b/test/files/jvm/actor-sync-send-timeout.scala
index 21e624bd0a..66a0b0a6ff 100644
--- a/test/files/jvm/actor-sync-send-timeout.scala
+++ b/test/files/jvm/actor-sync-send-timeout.scala
@@ -1,10 +1,11 @@
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.Actor
/* This test is a regression test for SI-4759.
*/
-object Test {
val Runs = 5
-
+
def main(args: Array[String]) = {
var i = 0
while (i < Runs) {
@@ -14,7 +15,6 @@ object Test {
}
//println("done sending to A1")
}
-}
object A2 extends Actor {
this.start()
@@ -45,3 +45,4 @@ object A1 extends Actor {
}
}
}
+}
diff --git a/test/files/jvm/actor-termination.scala b/test/files/jvm/actor-termination.scala
index d8e44a2797..4a6bf92d48 100644
--- a/test/files/jvm/actor-termination.scala
+++ b/test/files/jvm/actor-termination.scala
@@ -1,8 +1,9 @@
-import scala.actors.Actor
/* Test that an actor that hasn't finished prevents termination */
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.Actor
def main(args: Array[String]) {
Actor.actor {
try {
diff --git a/test/files/jvm/actor-uncaught-exception.scala b/test/files/jvm/actor-uncaught-exception.scala
index 5ae66de640..c28ad2fa3c 100644
--- a/test/files/jvm/actor-uncaught-exception.scala
+++ b/test/files/jvm/actor-uncaught-exception.scala
@@ -1,63 +1,64 @@
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.{Actor, Exit}
class MyException(msg: String) extends Exception(msg) {
override def fillInStackTrace() = this
}
-object Test {
- case object StartError extends Actor {
- def act() {
+ case object StartError extends Actor {
+ def act() {
try {
- throw new MyException("I don't want to run!")
+ throw new MyException("I don't want to run!")
} catch {
case e: Throwable if (!e.isInstanceOf[scala.util.control.ControlThrowable] &&
!e.isInstanceOf[MyException]) =>
e.printStackTrace()
}
- }
- }
+ }
+ }
- case object MessageError extends Actor {
- def act() {
+ case object MessageError extends Actor {
+ def act() {
try {
- react {
- case _ => throw new MyException("No message for me!")
- }
+ react {
+ case _ => throw new MyException("No message for me!")
+ }
} catch {
case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] =>
e.printStackTrace()
}
- }
- }
+ }
+ }
- case object Supervisor extends Actor {
- def act() {
+ case object Supervisor extends Actor {
+ def act() {
try {
- trapExit = true
+ trapExit = true
link(StartError)
link(MessageError)
- StartError.start()
+ StartError.start()
MessageError.start()
- Actor.loop {
- react {
+ Actor.loop {
+ react {
case Exit(actor, reason) =>
println("OK")
if (actor == StartError)
MessageError ! 'ping
else
exit()
- }
- }
+ }
+ }
} catch {
case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] =>
e.printStackTrace()
}
- }
- }
+ }
+ }
- def main(args: Array[String]) {
- Supervisor.start()
- }
-}
+ def main(args: Array[String]) {
+ Supervisor.start()
+ }
+}
diff --git a/test/files/jvm/actor-uncaught-exception2.check b/test/files/jvm/actor-uncaught-exception2.check
index 870a5d32f9..a54f374aed 100644
--- a/test/files/jvm/actor-uncaught-exception2.check
+++ b/test/files/jvm/actor-uncaught-exception2.check
@@ -1,2 +1,2 @@
-UncaughtException(StartError,None,None,MyException: I don't want to run!)
-UncaughtException(MessageError,Some('ping),Some(Supervisor),MyException: No message for me!)
+UncaughtException(StartError,None,None,Test$MyException: I don't want to run!)
+UncaughtException(MessageError,Some('ping),Some(Supervisor),Test$MyException: No message for me!)
diff --git a/test/files/jvm/actor-uncaught-exception2.scala b/test/files/jvm/actor-uncaught-exception2.scala
index 0364cbeb03..8327b4e19d 100644
--- a/test/files/jvm/actor-uncaught-exception2.scala
+++ b/test/files/jvm/actor-uncaught-exception2.scala
@@ -1,63 +1,63 @@
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.{Actor, Exit, Debug}
class MyException(msg: String) extends Exception(msg) {
override def fillInStackTrace() = this
}
-object Test {
-
- case object StartError extends Actor {
- def act() {
+ case object StartError extends Actor {
+ def act() {
try {
- throw new MyException("I don't want to run!")
+ throw new MyException("I don't want to run!")
} catch {
case e: Throwable if (!e.isInstanceOf[scala.util.control.ControlThrowable] &&
!e.isInstanceOf[MyException]) =>
e.printStackTrace()
}
- }
- }
+ }
+ }
- case object MessageError extends Actor {
- def act() {
+ case object MessageError extends Actor {
+ def act() {
try {
- react {
- case _ => throw new MyException("No message for me!")
- }
+ react {
+ case _ => throw new MyException("No message for me!")
+ }
} catch {
case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] =>
e.printStackTrace()
}
- }
- }
+ }
+ }
- case object Supervisor extends Actor {
- def act() {
+ case object Supervisor extends Actor {
+ def act() {
try {
- trapExit = true
+ trapExit = true
link(StartError)
link(MessageError)
- StartError.start()
+ StartError.start()
MessageError.start()
- Actor.loop {
- react {
+ Actor.loop {
+ react {
case Exit(actor, reason) =>
println(reason)
if (actor == StartError)
MessageError ! 'ping
else
exit()
- }
- }
+ }
+ }
} catch {
case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] =>
e.printStackTrace()
}
- }
- }
+ }
+ }
- def main(args: Array[String]) {
- Supervisor.start()
- }
-}
+ def main(args: Array[String]) {
+ Supervisor.start()
+ }
+}
diff --git a/test/files/jvm/annotations.scala b/test/files/jvm/annotations.scala
index 77a45fae89..c42eceef4c 100644
--- a/test/files/jvm/annotations.scala
+++ b/test/files/jvm/annotations.scala
@@ -1,3 +1,6 @@
+
+import scala.language.{ higherKinds, reflectiveCalls }
+
object Test1 {
class Foo {
@remote
diff --git a/test/files/jvm/backendBugUnapply.check b/test/files/jvm/backendBugUnapply.check
deleted file mode 100644
index 9d1e7b29c2..0000000000
--- a/test/files/jvm/backendBugUnapply.check
+++ /dev/null
@@ -1,2 +0,0 @@
-baz
-null
diff --git a/test/files/jvm/backendBugUnapply.scala b/test/files/jvm/backendBugUnapply.scala
deleted file mode 100644
index 45ee6f7d4f..0000000000
--- a/test/files/jvm/backendBugUnapply.scala
+++ /dev/null
@@ -1,17 +0,0 @@
-object Test {
- import scala.xml.{Node,UnprefixedAttribute}
-
- def domatch(x:Node) =
- x match {
- case Node("foo", UnprefixedAttribute("bar", z, _), _*) => z
- case _ => null
- }
-
- def main(args: Array[String]): Unit = {
- println(domatch(<foo bar="baz"><hi/></foo>))
- println(domatch(<foo bingo="donkey"><hi/></foo>))
- //
- // assert(domatch(<foo bar="baz"><hi/></foo>).toString == "baz")
- // assert(domatch(<foo bar="baz2"><hi/></foo>) == null)//, domatch(<foo bar="baz2"><hi/></foo>))
- }
-}
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/console.scala b/test/files/jvm/console.scala
index 75449416aa..0ac43f2d26 100644
--- a/test/files/jvm/console.scala
+++ b/test/files/jvm/console.scala
@@ -9,6 +9,6 @@ object Test extends App {
flush
println("..")
println(1)
- printf("Argument nr. %d has value %1.2f\n",
+ printf("Argument nr. %d has value %1.2f\n",
1, 10.0/3)
}
diff --git a/test/files/jvm/constant-optimization/Foo_1.flags b/test/files/jvm/constant-optimization/Foo_1.flags
new file mode 100644
index 0000000000..86f52af447
--- /dev/null
+++ b/test/files/jvm/constant-optimization/Foo_1.flags
@@ -0,0 +1 @@
+-Ynooptimise -Yconst-opt \ No newline at end of file
diff --git a/test/files/jvm/constant-optimization/Foo_1.scala b/test/files/jvm/constant-optimization/Foo_1.scala
new file mode 100644
index 0000000000..cb67ad4e90
--- /dev/null
+++ b/test/files/jvm/constant-optimization/Foo_1.scala
@@ -0,0 +1,9 @@
+class Foo_1 {
+ def foo() {
+ // constant optimization should eliminate all branches
+ val i = 1
+ val x = if (i != 1) null else "good"
+ val y = if (x == null) "good" else x + ""
+ println(y)
+ }
+} \ No newline at end of file
diff --git a/test/files/jvm/constant-optimization/Test.scala b/test/files/jvm/constant-optimization/Test.scala
new file mode 100644
index 0000000000..dc0f8f6103
--- /dev/null
+++ b/test/files/jvm/constant-optimization/Test.scala
@@ -0,0 +1,27 @@
+
+import scala.tools.partest.BytecodeTest
+import scala.tools.asm
+import asm.tree.InsnList
+import scala.collection.JavaConverters._
+
+object Test extends BytecodeTest {
+ val comparisons = Set(asm.Opcodes.IF_ACMPEQ, asm.Opcodes.IF_ACMPNE, asm.Opcodes.IF_ICMPEQ, asm.Opcodes.IF_ICMPGE, asm.Opcodes.IF_ICMPGT, asm.Opcodes.IF_ICMPLE,
+ asm.Opcodes.IF_ICMPLT, asm.Opcodes.IF_ICMPNE, asm.Opcodes.IFEQ, asm.Opcodes.IFGE, asm.Opcodes.IFGT, asm.Opcodes.IFLE, asm.Opcodes.IFLT,
+ asm.Opcodes.IFNE, asm.Opcodes.IFNONNULL, asm.Opcodes.IFNULL)
+
+ def show: Unit = {
+ val classNode = loadClassNode("Foo_1")
+ val methodNode = getMethod(classNode, "foo")
+ // after optimization there should be no comparisons left
+ val expected = 0
+
+ val got = countComparisons(methodNode.instructions)
+ assert(got == expected, s"expected $expected but got $got comparisons")
+ }
+
+ def countComparisons(insnList: InsnList): Int = {
+ def isComparison(node: asm.tree.AbstractInsnNode): Boolean =
+ (comparisons contains node.getOpcode)
+ insnList.iterator.asScala count isComparison
+ }
+} \ No newline at end of file
diff --git a/test/files/jvm/daemon-actor-termination.scala b/test/files/jvm/daemon-actor-termination.scala
index 6ddfc3139d..40acd8583e 100644
--- a/test/files/jvm/daemon-actor-termination.scala
+++ b/test/files/jvm/daemon-actor-termination.scala
@@ -1,8 +1,10 @@
-import scala.actors.{Actor, DaemonActor}
/* Test that a daemon Actor that hasn't finished does not prevent termination */
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.{Actor, DaemonActor}
class MyDaemon extends DaemonActor {
def act() {
try {
diff --git a/test/files/jvm/deprecation.check b/test/files/jvm/deprecation.check
new file mode 100644
index 0000000000..d116778d3f
--- /dev/null
+++ b/test/files/jvm/deprecation.check
@@ -0,0 +1,3 @@
+warning: there were 4 deprecation warning(s); re-run with -deprecation for details
+Note: deprecation/Use_2.java uses or overrides a deprecated API.
+Note: Recompile with -Xlint:deprecation for details.
diff --git a/test/files/jvm/deprecation/Test_1.scala b/test/files/jvm/deprecation/Test_1.scala
index b68a40c94b..0a5b607037 100644
--- a/test/files/jvm/deprecation/Test_1.scala
+++ b/test/files/jvm/deprecation/Test_1.scala
@@ -7,7 +7,7 @@ class Test {
val i = new d.Inner
val w = i.buz()
}
-
+
@deprecated("no longer!", "") class Inner {
@deprecated("uncool", "") def f: Int = 1
@deprecated("this one as well!", "") var g = -1
diff --git a/test/files/jvm/duration-tck.scala b/test/files/jvm/duration-tck.scala
index b2573448c7..3bc8a2c100 100644
--- a/test/files/jvm/duration-tck.scala
+++ b/test/files/jvm/duration-tck.scala
@@ -6,6 +6,8 @@ import scala.concurrent.duration._
import scala.reflect._
import scala.tools.partest.TestUtil.intercept
+import scala.language.{ postfixOps }
+
object Test extends App {
implicit class Assert(val left: Any) extends AnyVal {
diff --git a/test/files/jvm/future-alarm.scala b/test/files/jvm/future-alarm.scala
index 8ee902b5ea..3e71fa681c 100644
--- a/test/files/jvm/future-alarm.scala
+++ b/test/files/jvm/future-alarm.scala
@@ -1,6 +1,8 @@
-import scala.actors.Futures
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.Futures
def main(args: Array[String]) {
try {
for (i <- 1 to 100000) {
diff --git a/test/files/jvm/future-awaitall-zero.scala b/test/files/jvm/future-awaitall-zero.scala
index cd6ba172cc..56f4bab16f 100644
--- a/test/files/jvm/future-awaitall-zero.scala
+++ b/test/files/jvm/future-awaitall-zero.scala
@@ -1,7 +1,9 @@
-import scala.actors.Futures._
-import scala.actors.Actor._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.Futures._
+ import scala.actors.Actor._
def main(args: Array[String]) {
try {
val ft1 = future { reactWithin(10000) {
diff --git a/test/files/jvm/future-spec.check b/test/files/jvm/future-spec.check
new file mode 100644
index 0000000000..844ca54682
--- /dev/null
+++ b/test/files/jvm/future-spec.check
@@ -0,0 +1 @@
+warning: there were 1 deprecation warning(s); re-run with -deprecation for details
diff --git a/test/files/jvm/future-spec/FutureTests.scala b/test/files/jvm/future-spec/FutureTests.scala
index ddd819c109..cfdcc31ac5 100644
--- a/test/files/jvm/future-spec/FutureTests.scala
+++ b/test/files/jvm/future-spec/FutureTests.scala
@@ -10,18 +10,18 @@ import scala.util.{Try,Success,Failure}
-object FutureTests extends MinimalScalaTest {
+class FutureTests extends MinimalScalaTest {
/* some utils */
-
+
def testAsync(s: String)(implicit ec: ExecutionContext): Future[String] = s match {
- case "Hello" => future { "World" }
+ case "Hello" => Future { "World" }
case "Failure" => Future.failed(new RuntimeException("Expected exception; to test fault-tolerance"))
case "NoReply" => Promise[String]().future
}
-
+
val defaultTimeout = 5 seconds
-
+
/* future specification */
"A future with custom ExecutionContext" should {
@@ -31,41 +31,41 @@ object FutureTests extends MinimalScalaTest {
t =>
ms += t
})
-
+
class ThrowableTest(m: String) extends Throwable(m)
-
- val f1 = future[Any] {
+
+ val f1 = Future[Any] {
throw new ThrowableTest("test")
}
-
+
intercept[ThrowableTest] {
Await.result(f1, defaultTimeout)
}
-
+
val latch = new TestLatch
- val f2 = future {
+ val f2 = Future {
Await.ready(latch, 5 seconds)
"success"
}
val f3 = f2 map { s => s.toUpperCase }
-
+
f2 foreach { _ => throw new ThrowableTest("dispatcher foreach") }
f2 onSuccess { case _ => throw new ThrowableTest("dispatcher receive") }
-
+
latch.open()
-
+
Await.result(f2, defaultTimeout) mustBe ("success")
-
+
f2 foreach { _ => throw new ThrowableTest("current thread foreach") }
f2 onSuccess { case _ => throw new ThrowableTest("current thread receive") }
-
+
Await.result(f3, defaultTimeout) mustBe ("SUCCESS")
-
- val waiting = future {
+
+ val waiting = Future {
Thread.sleep(1000)
}
Await.ready(waiting, 2000 millis)
-
+
ms.size mustBe (4)
//FIXME should check
}
@@ -96,7 +96,7 @@ object FutureTests extends MinimalScalaTest {
val logThrowable: Throwable => Unit = p.trySuccess(_)
val ec: ExecutionContext = ExecutionContext.fromExecutor(null, logThrowable)
- val t = new NotImplementedError("foo")
+ val t = new InterruptedException()
val f = Future(throw t)(ec)
Await.result(p.future, 2.seconds) mustBe t
}
@@ -106,73 +106,73 @@ object FutureTests extends MinimalScalaTest {
import ExecutionContext.Implicits._
"compose with for-comprehensions" in {
- def async(x: Int) = future { (x * 2).toString }
- val future0 = future[Any] {
+ def async(x: Int) = Future { (x * 2).toString }
+ val future0 = Future[Any] {
"five!".length
}
-
+
val future1 = for {
a <- future0.mapTo[Int] // returns 5
b <- async(a) // returns "10"
c <- async(7) // returns "14"
} yield b + "-" + c
-
+
val future2 = for {
a <- future0.mapTo[Int]
- b <- (future { (a * 2).toString }).mapTo[Int]
- c <- future { (7 * 2).toString }
+ b <- (Future { (a * 2).toString }).mapTo[Int]
+ c <- Future { (7 * 2).toString }
} yield b + "-" + c
-
+
Await.result(future1, defaultTimeout) mustBe ("10-14")
assert(checkType(future1, manifest[String]))
intercept[ClassCastException] { Await.result(future2, defaultTimeout) }
}
-
+
"support pattern matching within a for-comprehension" in {
case class Req[T](req: T)
case class Res[T](res: T)
def async[T](req: Req[T]) = req match {
- case Req(s: String) => future { Res(s.length) }
- case Req(i: Int) => future { Res((i * 2).toString) }
+ case Req(s: String) => Future { Res(s.length) }
+ case Req(i: Int) => Future { Res((i * 2).toString) }
}
-
+
val future1 = for {
Res(a: Int) <- async(Req("Hello"))
Res(b: String) <- async(Req(a))
Res(c: String) <- async(Req(7))
} yield b + "-" + c
-
+
val future2 = for {
Res(a: Int) <- async(Req("Hello"))
Res(b: Int) <- async(Req(a))
Res(c: Int) <- async(Req(7))
} yield b + "-" + c
-
+
Await.result(future1, defaultTimeout) mustBe ("10-14")
intercept[NoSuchElementException] { Await.result(future2, defaultTimeout) }
}
-
+
"recover from exceptions" in {
val future1 = Future(5)
val future2 = future1 map (_ / 0)
val future3 = future2 map (_.toString)
-
+
val future4 = future1 recover {
case e: ArithmeticException => 0
} map (_.toString)
-
+
val future5 = future2 recover {
case e: ArithmeticException => 0
} map (_.toString)
-
+
val future6 = future2 recover {
case e: MatchError => 0
} map (_.toString)
-
+
val future7 = future3 recover {
case e: ArithmeticException => "You got ERROR"
}
-
+
val future8 = testAsync("Failure")
val future9 = testAsync("Failure") recover {
case e: RuntimeException => "FAIL!"
@@ -183,7 +183,7 @@ object FutureTests extends MinimalScalaTest {
val future11 = testAsync("Failure") recover {
case _ => "Oops!"
}
-
+
Await.result(future1, defaultTimeout) mustBe (5)
intercept[ArithmeticException] { Await.result(future2, defaultTimeout) }
intercept[ArithmeticException] { Await.result(future3, defaultTimeout) }
@@ -196,23 +196,23 @@ object FutureTests extends MinimalScalaTest {
Await.result(future10, defaultTimeout) mustBe ("World")
Await.result(future11, defaultTimeout) mustBe ("Oops!")
}
-
+
"recoverWith from exceptions" in {
val o = new IllegalStateException("original")
val r = new IllegalStateException("recovered")
-
+
intercept[IllegalStateException] {
val failed = Future.failed[String](o) recoverWith {
case _ if false == true => Future.successful("yay!")
}
Await.result(failed, defaultTimeout)
} mustBe (o)
-
+
val recovered = Future.failed[String](o) recoverWith {
case _ => Future.successful("yay!")
}
Await.result(recovered, defaultTimeout) mustBe ("yay!")
-
+
intercept[IllegalStateException] {
val refailed = Future.failed[String](o) recoverWith {
case _ => Future.failed[String](r)
@@ -220,11 +220,11 @@ object FutureTests extends MinimalScalaTest {
Await.result(refailed, defaultTimeout)
} mustBe (r)
}
-
+
"andThen like a boss" in {
val q = new java.util.concurrent.LinkedBlockingQueue[Int]
for (i <- 1 to 1000) {
- val chained = future {
+ val chained = Future {
q.add(1); 3
} andThen {
case _ => q.add(2)
@@ -240,28 +240,28 @@ object FutureTests extends MinimalScalaTest {
q.clear()
}
}
-
+
"firstCompletedOf" in {
def futures = Vector.fill[Future[Int]](10) {
Promise[Int]().future
} :+ Future.successful[Int](5)
-
+
Await.result(Future.firstCompletedOf(futures), defaultTimeout) mustBe (5)
Await.result(Future.firstCompletedOf(futures.iterator), defaultTimeout) mustBe (5)
}
-
+
"find" in {
- val futures = for (i <- 1 to 10) yield future {
+ val futures = for (i <- 1 to 10) yield Future {
i
}
-
+
val result = Future.find[Int](futures)(_ == 3)
Await.result(result, defaultTimeout) mustBe (Some(3))
val notFound = Future.find[Int](futures.iterator)(_ == 11)
Await.result(notFound, defaultTimeout) mustBe (None)
}
-
+
"zip" in {
val timeout = 10000 millis
val f = new IllegalStateException("test")
@@ -269,48 +269,48 @@ object FutureTests extends MinimalScalaTest {
val failed = Future.failed[String](f) zip Future.successful("foo")
Await.result(failed, timeout)
} mustBe (f)
-
+
intercept[IllegalStateException] {
val failed = Future.successful("foo") zip Future.failed[String](f)
Await.result(failed, timeout)
} mustBe (f)
-
+
intercept[IllegalStateException] {
val failed = Future.failed[String](f) zip Future.failed[String](f)
Await.result(failed, timeout)
} mustBe (f)
-
+
val successful = Future.successful("foo") zip Future.successful("foo")
Await.result(successful, timeout) mustBe (("foo", "foo"))
}
-
+
"fold" in {
val timeout = 10000 millis
- def async(add: Int, wait: Int) = future {
+ def async(add: Int, wait: Int) = Future {
Thread.sleep(wait)
add
}
-
+
val futures = (0 to 9) map {
idx => async(idx, idx * 20)
}
val folded = Future.fold(futures)(0)(_ + _)
Await.result(folded, timeout) mustBe (45)
-
+
val futuresit = (0 to 9) map {
idx => async(idx, idx * 20)
}
val foldedit = Future.fold(futures)(0)(_ + _)
Await.result(foldedit, timeout) mustBe (45)
}
-
+
"fold by composing" in {
val timeout = 10000 millis
- def async(add: Int, wait: Int) = future {
+ def async(add: Int, wait: Int) = Future {
Thread.sleep(wait)
add
}
- def futures = (0 to 9) map {
+ def futures = (0 to 9) map {
idx => async(idx, idx * 20)
}
val folded = futures.foldLeft(Future(0)) {
@@ -318,10 +318,10 @@ object FutureTests extends MinimalScalaTest {
}
Await.result(folded, timeout) mustBe (45)
}
-
+
"fold with an exception" in {
val timeout = 10000 millis
- def async(add: Int, wait: Int) = future {
+ def async(add: Int, wait: Int) = Future {
Thread.sleep(wait)
if (add == 6) throw new IllegalArgumentException("shouldFoldResultsWithException: expected")
add
@@ -334,7 +334,7 @@ object FutureTests extends MinimalScalaTest {
Await.result(folded, timeout)
}.getMessage mustBe ("shouldFoldResultsWithException: expected")
}
-
+
"fold mutable zeroes safely" in {
import scala.collection.mutable.ArrayBuffer
def test(testNumber: Int) {
@@ -344,36 +344,36 @@ object FutureTests extends MinimalScalaTest {
case (l, _) => l
}
val result = Await.result(f.mapTo[ArrayBuffer[Int]], 10000 millis).sum
-
+
assert(result == 250500)
}
(1 to 100) foreach test //Make sure it tries to provoke the problem
}
-
+
"return zero value if folding empty list" in {
val zero = Future.fold(List[Future[Int]]())(0)(_ + _)
Await.result(zero, defaultTimeout) mustBe (0)
}
-
+
"shouldReduceResults" in {
- def async(idx: Int) = future {
+ def async(idx: Int) = Future {
Thread.sleep(idx * 20)
idx
}
val timeout = 10000 millis
-
+
val futures = (0 to 9) map { async }
val reduced = Future.reduce(futures)(_ + _)
Await.result(reduced, timeout) mustBe (45)
-
+
val futuresit = (0 to 9) map { async }
val reducedit = Future.reduce(futuresit)(_ + _)
Await.result(reducedit, timeout) mustBe (45)
}
-
+
"shouldReduceResultsWithException" in {
- def async(add: Int, wait: Int) = future {
+ def async(add: Int, wait: Int) = Future {
Thread.sleep(wait)
if (add == 6) throw new IllegalArgumentException("shouldFoldResultsWithException: expected")
else add
@@ -387,14 +387,14 @@ object FutureTests extends MinimalScalaTest {
Await.result(failed, timeout)
}.getMessage mustBe ("shouldFoldResultsWithException: expected")
}
-
+
"shouldReduceThrowNSEEOnEmptyInput" in {
intercept[java.util.NoSuchElementException] {
val emptyreduced = Future.reduce(List[Future[Int]]())(_ + _)
Await.result(emptyreduced, defaultTimeout)
}
}
-
+
"shouldTraverseFutures" in {
object counter {
var count = -1
@@ -403,54 +403,54 @@ object FutureTests extends MinimalScalaTest {
count
}
}
-
- val oddFutures = List.fill(100)(future { counter.incAndGet() }).iterator
+
+ val oddFutures = List.fill(100)(Future { counter.incAndGet() }).iterator
val traversed = Future.sequence(oddFutures)
Await.result(traversed, defaultTimeout).sum mustBe (10000)
-
+
val list = (1 to 100).toList
val traversedList = Future.traverse(list)(x => Future(x * 2 - 1))
Await.result(traversedList, defaultTimeout).sum mustBe (10000)
-
+
val iterator = (1 to 100).toList.iterator
val traversedIterator = Future.traverse(iterator)(x => Future(x * 2 - 1))
Await.result(traversedIterator, defaultTimeout).sum mustBe (10000)
}
-
+
"shouldBlockUntilResult" in {
val latch = new TestLatch
-
- val f = future {
+
+ val f = Future {
Await.ready(latch, 5 seconds)
5
}
- val f2 = future {
+ val f2 = Future {
val res = Await.result(f, Inf)
res + 9
}
-
+
intercept[TimeoutException] {
Await.ready(f2, 100 millis)
}
-
+
latch.open()
-
+
Await.result(f2, defaultTimeout) mustBe (14)
-
- val f3 = future {
+
+ val f3 = Future {
Thread.sleep(100)
5
}
-
+
intercept[TimeoutException] {
Await.ready(f3, 0 millis)
}
}
-
+
"run callbacks async" in {
val latch = Vector.fill(10)(new TestLatch)
-
- val f1 = future {
+
+ val f1 = Future {
latch(0).open()
Await.ready(latch(1), TestLatch.DefaultTimeout)
"Hello"
@@ -462,18 +462,18 @@ object FutureTests extends MinimalScalaTest {
s.length
}
for (_ <- f2) latch(4).open()
-
+
Await.ready(latch(0), TestLatch.DefaultTimeout)
-
+
f1.isCompleted mustBe (false)
f2.isCompleted mustBe (false)
-
+
latch(1).open()
Await.ready(latch(2), TestLatch.DefaultTimeout)
-
+
f1.isCompleted mustBe (true)
f2.isCompleted mustBe (false)
-
+
val f3 = f1 map {
s =>
latch(5).open()
@@ -481,17 +481,17 @@ object FutureTests extends MinimalScalaTest {
s.length * 2
}
for (_ <- f3) latch(3).open()
-
+
Await.ready(latch(5), TestLatch.DefaultTimeout)
-
+
f3.isCompleted mustBe (false)
-
+
latch(6).open()
Await.ready(latch(4), TestLatch.DefaultTimeout)
-
+
f2.isCompleted mustBe (true)
f3.isCompleted mustBe (true)
-
+
val p1 = Promise[String]()
val f4 = p1.future map {
s =>
@@ -500,23 +500,23 @@ object FutureTests extends MinimalScalaTest {
s.length
}
for (_ <- f4) latch(9).open()
-
+
p1.future.isCompleted mustBe (false)
f4.isCompleted mustBe (false)
-
+
p1 complete Success("Hello")
-
+
Await.ready(latch(7), TestLatch.DefaultTimeout)
-
+
p1.future.isCompleted mustBe (true)
f4.isCompleted mustBe (false)
-
+
latch(8).open()
Await.ready(latch(9), TestLatch.DefaultTimeout)
-
+
Await.ready(f4, defaultTimeout).isCompleted mustBe (true)
}
-
+
"should not deadlock with nested await (ticket 1313)" in {
val simple = Future() map {
_ =>
@@ -525,7 +525,7 @@ object FutureTests extends MinimalScalaTest {
Await.result(umap, Inf)
}
Await.ready(simple, Inf).isCompleted mustBe (true)
-
+
val l1, l2 = new TestLatch
val complex = Future() map {
_ =>
@@ -542,12 +542,12 @@ object FutureTests extends MinimalScalaTest {
"should not throw when Await.ready" in {
val expected = try Success(5 / 0) catch { case a: ArithmeticException => Failure(a) }
- val f = future(5).map(_ / 0)
+ val f = Future(5).map(_ / 0)
Await.ready(f, defaultTimeout).value.get.toString mustBe expected.toString
}
-
+
}
-
+
}
diff --git a/test/files/jvm/future-spec/PromiseTests.scala b/test/files/jvm/future-spec/PromiseTests.scala
index 48f94666ba..12b9168c5d 100644
--- a/test/files/jvm/future-spec/PromiseTests.scala
+++ b/test/files/jvm/future-spec/PromiseTests.scala
@@ -9,33 +9,33 @@ import scala.runtime.NonLocalReturnControl
import scala.util.{Try,Success,Failure}
-object PromiseTests extends MinimalScalaTest {
+class PromiseTests extends MinimalScalaTest {
import ExecutionContext.Implicits._
val defaultTimeout = Inf
-
+
/* promise specification */
-
+
"An empty Promise" should {
-
+
"not be completed" in {
val p = Promise()
p.future.isCompleted mustBe (false)
p.isCompleted mustBe (false)
}
-
+
"have no value" in {
val p = Promise()
p.future.value mustBe (None)
p.isCompleted mustBe (false)
}
-
+
"return supplied value on timeout" in {
val failure = Promise.failed[String](new RuntimeException("br0ken")).future
val otherFailure = Promise.failed[String](new RuntimeException("last")).future
val empty = Promise[String]().future
val timedOut = Promise.successful[String]("Timedout").future
-
+
Await.result(failure fallbackTo timedOut, defaultTimeout) mustBe ("Timedout")
Await.result(timedOut fallbackTo empty, defaultTimeout) mustBe ("Timedout")
Await.result(otherFailure fallbackTo failure fallbackTo timedOut, defaultTimeout) mustBe ("Timedout")
@@ -43,47 +43,47 @@ object PromiseTests extends MinimalScalaTest {
Await.result(failure fallbackTo otherFailure, defaultTimeout)
}.getMessage mustBe ("br0ken")
}
-
+
}
-
+
"A successful Promise" should {
val result = "test value"
val promise = Promise[String]().complete(Success(result))
promise.isCompleted mustBe (true)
futureWithResult(_(promise.future, result))
}
-
+
"A failed Promise" should {
val message = "Expected Exception"
val promise = Promise[String]().complete(Failure(new RuntimeException(message)))
promise.isCompleted mustBe (true)
futureWithException[RuntimeException](_(promise.future, message))
}
-
+
"An interrupted Promise" should {
val message = "Boxed InterruptedException"
val future = Promise[String]().complete(Failure(new InterruptedException(message))).future
futureWithException[ExecutionException](_(future, message))
}
-
+
"A NonLocalReturnControl failed Promise" should {
val result = "test value"
val future = Promise[String]().complete(Failure(new NonLocalReturnControl[String]("test", result))).future
futureWithResult(_(future, result))
}
-
+
def futureWithResult(f: ((Future[Any], Any) => Unit) => Unit) {
-
+
"be completed" in { f((future, _) => future.isCompleted mustBe (true)) }
-
+
"contain a value" in { f((future, result) => future.value mustBe (Some(Success(result)))) }
-
+
"return when ready with 'Await.ready'" in { f((future, result) => Await.ready(future, defaultTimeout).isCompleted mustBe (true)) }
-
+
"return result with 'Await.result'" in { f((future, result) => Await.result(future, defaultTimeout) mustBe (result)) }
-
+
"not timeout" in { f((future, _) => Await.ready(future, 0 millis)) }
-
+
"filter result" in {
f {
(future, result) =>
@@ -93,16 +93,16 @@ object PromiseTests extends MinimalScalaTest {
}
}
}
-
+
"transform result with map" in { f((future, result) => Await.result((future map (_.toString.length)), defaultTimeout) mustBe (result.toString.length)) }
-
+
"compose result with flatMap" in {
f { (future, result) =>
val r = for (r <- future; p <- Promise.successful("foo").future) yield r.toString + p
Await.result(r, defaultTimeout) mustBe (result.toString + "foo")
}
}
-
+
"perform action with foreach" in {
f {
(future, result) =>
@@ -111,7 +111,7 @@ object PromiseTests extends MinimalScalaTest {
Await.result(p.future, defaultTimeout) mustBe (result)
}
}
-
+
"zip properly" in {
f {
(future, result) =>
@@ -121,9 +121,9 @@ object PromiseTests extends MinimalScalaTest {
}.getMessage mustBe ("ohnoes")
}
}
-
+
"not recover from exception" in { f((future, result) => Await.result(future.recover({ case _ => "pigdog" }), defaultTimeout) mustBe (result)) }
-
+
"perform action on result" in {
f {
(future, result) =>
@@ -132,7 +132,7 @@ object PromiseTests extends MinimalScalaTest {
Await.result(p.future, defaultTimeout) mustBe (result)
}
}
-
+
"not project a failure" in {
f {
(future, result) =>
@@ -141,34 +141,34 @@ object PromiseTests extends MinimalScalaTest {
}.getMessage mustBe ("Future.failed not completed with a throwable.")
}
}
-
+
"cast using mapTo" in {
f {
(future, result) =>
Await.result(future.mapTo[Boolean].recover({ case _: ClassCastException ⇒ false }), defaultTimeout) mustBe (false)
}
}
-
+
}
def futureWithException[E <: Throwable: Manifest](f: ((Future[Any], String) => Unit) => Unit) {
-
+
"be completed" in {
f((future, _) => future.isCompleted mustBe (true))
}
-
+
"contain a value" in {
f((future, message) => {
future.value.get.failed.get.getMessage mustBe (message)
})
}
-
+
"throw not throw exception with 'Await.ready'" in {
f {
(future, message) => Await.ready(future, defaultTimeout).isCompleted mustBe (true)
}
}
-
+
"throw exception with 'Await.result'" in {
f {
(future, message) =>
@@ -177,7 +177,7 @@ object PromiseTests extends MinimalScalaTest {
}.getMessage mustBe (message)
}
}
-
+
"retain exception with filter" in {
f {
(future, message) =>
@@ -185,21 +185,21 @@ object PromiseTests extends MinimalScalaTest {
intercept[E] { Await.result(future filter (_ => false), defaultTimeout) }.getMessage mustBe (message)
}
}
-
+
"retain exception with map" in {
f {
(future, message) =>
intercept[E] { Await.result(future map (_.toString.length), defaultTimeout) }.getMessage mustBe (message)
}
}
-
+
"retain exception with flatMap" in {
f {
(future, message) =>
intercept[E] { Await.result(future flatMap (_ => Promise.successful("foo").future), defaultTimeout) }.getMessage mustBe (message)
}
}
-
+
"zip properly" in {
f {
(future, message) =>
@@ -208,18 +208,18 @@ object PromiseTests extends MinimalScalaTest {
}.getMessage mustBe (message)
}
}
-
+
"recover from exception" in {
f {
(future, message) =>
Await.result(future.recover({ case e if e.getMessage == message ⇒ "pigdog" }), defaultTimeout) mustBe ("pigdog")
}
}
-
+
"project a failure" in {
f((future, message) => Await.result(future.failed, defaultTimeout).getMessage mustBe (message))
}
-
+
"perform action on exception" in {
f {
(future, message) =>
@@ -228,7 +228,7 @@ object PromiseTests extends MinimalScalaTest {
Await.result(p.future, defaultTimeout) mustBe (message)
}
}
-
+
"always cast successfully using mapTo" in {
f {
(future, message) =>
diff --git a/test/files/jvm/future-spec/TryTests.scala b/test/files/jvm/future-spec/TryTests.scala
index 5d1b9b84b4..01bb3c9d36 100644
--- a/test/files/jvm/future-spec/TryTests.scala
+++ b/test/files/jvm/future-spec/TryTests.scala
@@ -5,7 +5,7 @@
import scala.util.{Try,Success,Failure}
-object TryTests extends MinimalScalaTest {
+class TryTests extends MinimalScalaTest {
class MyException extends Exception
val e = new Exception("this is an exception")
diff --git a/test/files/jvm/future-spec/main.scala b/test/files/jvm/future-spec/main.scala
index 90048ccda0..697d0fe91f 100644
--- a/test/files/jvm/future-spec/main.scala
+++ b/test/files/jvm/future-spec/main.scala
@@ -8,40 +8,46 @@ import java.util.concurrent.{ TimeoutException, CountDownLatch, TimeUnit }
object Test {
-
+
def main(args: Array[String]) {
- FutureTests.check()
- PromiseTests.check()
- TryTests.check()
+ (new FutureTests).check()
+ (new PromiseTests).check()
+ (new TryTests).check()
}
-
+
+}
+
+trait Features {
+ implicit def implicitously = scala.language.implicitConversions
+ implicit def reflectively = scala.language.reflectiveCalls
+ implicit def postulously = scala.language.postfixOps
}
trait Output {
val buffer = new StringBuilder
-
+
def bufferPrintln(a: Any) = buffer.synchronized {
buffer.append(a.toString + "\n")
}
}
-trait MinimalScalaTest extends Output {
-
+trait MinimalScalaTest extends Output with Features {
+
val throwables = mutable.ArrayBuffer[Throwable]()
-
+
def check() {
if (throwables.nonEmpty) println(buffer.toString)
}
-
+
implicit def stringops(s: String) = new {
-
+
def should[U](snippets: =>U) = {
bufferPrintln(s + " should:")
snippets
}
-
+
def in[U](snippet: =>U) = {
try {
bufferPrintln("- " + s)
@@ -54,27 +60,27 @@ trait MinimalScalaTest extends Output {
throwables += e
}
}
-
+
}
-
+
implicit def objectops(obj: Any) = new {
-
+
def mustBe(other: Any) = assert(obj == other, obj + " is not " + other)
def mustEqual(other: Any) = mustBe(other)
-
+
}
-
+
def intercept[T <: Throwable: Manifest](body: =>Any): T = {
try {
body
throw new Exception("Exception of type %s was not thrown".format(manifest[T]))
} catch {
case t: Throwable =>
- if (manifest[T].erasure != t.getClass) throw t
+ if (manifest[T].runtimeClass != t.getClass) throw t
else t.asInstanceOf[T]
}
}
-
+
def checkType[T: Manifest, S](in: Future[T], refmanifest: Manifest[S]): Boolean = manifest[T] == refmanifest
}
@@ -88,23 +94,23 @@ object TestLatch {
class TestLatch(count: Int = 1) extends Awaitable[Unit] {
private var latch = new CountDownLatch(count)
-
+
def countDown() = latch.countDown()
def isOpen: Boolean = latch.getCount == 0
def open() = while (!isOpen) countDown()
def reset() = latch = new CountDownLatch(count)
-
+
@throws(classOf[TimeoutException])
def ready(atMost: Duration)(implicit permit: CanAwait) = {
val opened = latch.await(atMost.toNanos, TimeUnit.NANOSECONDS)
if (!opened) throw new TimeoutException("Timeout of %s." format (atMost.toString))
this
}
-
+
@throws(classOf[Exception])
def result(atMost: Duration)(implicit permit: CanAwait): Unit = {
ready(atMost)
}
-
+
}
diff --git a/test/files/jvm/future-termination.scala b/test/files/jvm/future-termination.scala
index f51642cb7a..90ea336ce8 100644
--- a/test/files/jvm/future-termination.scala
+++ b/test/files/jvm/future-termination.scala
@@ -1,19 +1,21 @@
-import scala.actors.Futures
-
-/* Test that unevaluated futures do not prevent program termination */
-
-object Test {
- def main(args: Array[String]) {
+
+/* Test that unevaluated futures do not prevent program termination */
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
+ import scala.actors.Futures
+ def main(args: Array[String]) {
try {
- val meaningOfLife = Futures.future {
- Thread.sleep(5000) // pretend this is a harder problem than it is
- println("I have the answer!")
- 42
- }
- println("I can't wait that long, bye.")
+ val meaningOfLife = Futures.future {
+ Thread.sleep(5000) // pretend this is a harder problem than it is
+ println("I have the answer!")
+ 42
+ }
+ println("I can't wait that long, bye.")
} catch {
case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] =>
e.printStackTrace()
}
- }
+ }
}
diff --git a/test/files/jvm/inner.scala b/test/files/jvm/inner.scala
index 009d52e5bc..c05e803449 100644
--- a/test/files/jvm/inner.scala
+++ b/test/files/jvm/inner.scala
@@ -14,7 +14,7 @@ class A {
trait Itf {
def method1(x: Int): Int
-
+
trait Itf2 extends Itf {
def method2: Unit
}
diff --git a/test/files/jvm/interpreter.check b/test/files/jvm/interpreter.check
index 96b57c7742..6e5fada381 100644
--- a/test/files/jvm/interpreter.check
+++ b/test/files/jvm/interpreter.check
@@ -1,8 +1,6 @@
Type in expressions to have them evaluated.
Type :help for more information.
-scala>
-
scala> // basics
scala> 3+4
@@ -301,7 +299,7 @@ scala> <a>
c="c"
d="dd"
/></a>
-res8: scala.xml.Elem =
+res8: scala.xml.Elem =
<a>
<b c="c" d="dd"/></a>
@@ -324,7 +322,7 @@ scala> """
hello
there
"""
-res12: String =
+res12: String =
"
hello
there
@@ -357,17 +355,13 @@ defined class Term
scala> def f(e: Exp) = e match { // non-exhaustive warning here
case _:Fact => 3
}
-<console>:18: warning: match is not exhaustive!
-missing combination Exp
-missing combination Term
-
+<console>:18: warning: match may not be exhaustive.
+It would fail on the following inputs: Exp(), Term()
def f(e: Exp) = e match { // non-exhaustive warning here
^
f: (e: Exp)Int
scala>
-
-scala>
plusOne: (x: Int)Int
res0: Int = 6
res0: String = after reset
diff --git a/test/files/jvm/interpreter.scala b/test/files/jvm/interpreter.scala
index f45eb034a9..bd1851053f 100644
--- a/test/files/jvm/interpreter.scala
+++ b/test/files/jvm/interpreter.scala
@@ -2,7 +2,7 @@ import scala.tools.nsc._
import scala.tools.partest.ReplTest
object Test extends ReplTest {
- override def extraSettings = "-deprecation -Xoldpatmat"
+ override def extraSettings = "-deprecation"
def code = <code>
// basics
3+4
diff --git a/test/files/jvm/manifests-new.check b/test/files/jvm/manifests-new.check
index a1ff9491cf..7b229ba679 100644
--- a/test/files/jvm/manifests-new.check
+++ b/test/files/jvm/manifests-new.check
@@ -31,8 +31,8 @@ x=Foo, t=TypeTag[Foo[List[Int]]], k=TypeRef, s=class Foo
x=Foo, t=TypeTag[Foo[Foo[Int]]], k=TypeRef, s=class Foo
x=Foo, t=TypeTag[Foo[List[Foo[Int]]]], k=TypeRef, s=class Foo
-x=Test1$$anon$1, t=TypeTag[Bar[String]], k=RefinedType, s=<local Test1>
-x=Test1$$anon$2, t=TypeTag[Bar[String]], k=RefinedType, s=<local Test1>
+x=Test1$$anon$1, t=TypeTag[Bar[String]], k=RefinedType, s=<refinement of Bar[String]>
+x=Test1$$anon$2, t=TypeTag[Bar[String]], k=RefinedType, s=<refinement of Bar[String]>
()=()
true=true
diff --git a/test/files/jvm/manifests-new.scala b/test/files/jvm/manifests-new.scala
index f730be67bb..3937fdec69 100644
--- a/test/files/jvm/manifests-new.scala
+++ b/test/files/jvm/manifests-new.scala
@@ -56,7 +56,7 @@ object Test1 extends TestUtil {
}
object Test2 {
- import scala.util.Marshal._
+ import Marshal._
println("()="+load[Unit](dump(())))
println("true="+load[Boolean](dump(true)))
println("a="+load[Char](dump('a')))
@@ -88,6 +88,38 @@ object Test2 {
println()
}
+object Marshal {
+ import java.io._
+ import scala.reflect.ClassTag
+
+ def dump[A](o: A)(implicit t: ClassTag[A]): Array[Byte] = {
+ val ba = new ByteArrayOutputStream(512)
+ val out = new ObjectOutputStream(ba)
+ out.writeObject(t)
+ out.writeObject(o)
+ out.close()
+ ba.toByteArray()
+ }
+
+ @throws(classOf[IOException])
+ @throws(classOf[ClassCastException])
+ @throws(classOf[ClassNotFoundException])
+ def load[A](buffer: Array[Byte])(implicit expected: ClassTag[A]): A = {
+ val in = new ObjectInputStream(new ByteArrayInputStream(buffer))
+ val found = in.readObject.asInstanceOf[ClassTag[_]]
+ try {
+ found.runtimeClass.asSubclass(expected.runtimeClass)
+ in.readObject.asInstanceOf[A]
+ } catch {
+ case _: ClassCastException =>
+ in.close()
+ throw new ClassCastException("type mismatch;"+
+ "\n found : "+found+
+ "\n required: "+expected)
+ }
+ }
+}
+
trait TestUtil {
import java.io._
def write[A](o: A): Array[Byte] = {
diff --git a/test/files/jvm/manifests-old.scala b/test/files/jvm/manifests-old.scala
index 241966fd9d..bb1928f094 100644
--- a/test/files/jvm/manifests-old.scala
+++ b/test/files/jvm/manifests-old.scala
@@ -55,7 +55,7 @@ object Test1 extends TestUtil {
}
object Test2 {
- import scala.util.Marshal._
+ import Marshal._
println("()="+load[Unit](dump(())))
println("true="+load[Boolean](dump(true)))
println("a="+load[Char](dump('a')))
@@ -87,6 +87,38 @@ object Test2 {
println()
}
+object Marshal {
+ import java.io._
+ import scala.reflect.ClassTag
+
+ def dump[A](o: A)(implicit t: ClassTag[A]): Array[Byte] = {
+ val ba = new ByteArrayOutputStream(512)
+ val out = new ObjectOutputStream(ba)
+ out.writeObject(t)
+ out.writeObject(o)
+ out.close()
+ ba.toByteArray()
+ }
+
+ @throws(classOf[IOException])
+ @throws(classOf[ClassCastException])
+ @throws(classOf[ClassNotFoundException])
+ def load[A](buffer: Array[Byte])(implicit expected: ClassTag[A]): A = {
+ val in = new ObjectInputStream(new ByteArrayInputStream(buffer))
+ val found = in.readObject.asInstanceOf[ClassTag[_]]
+ try {
+ found.runtimeClass.asSubclass(expected.runtimeClass)
+ in.readObject.asInstanceOf[A]
+ } catch {
+ case _: ClassCastException =>
+ in.close()
+ throw new ClassCastException("type mismatch;"+
+ "\n found : "+found+
+ "\n required: "+expected)
+ }
+ }
+}
+
trait TestUtil {
import java.io._
def write[A](o: A): Array[Byte] = {
diff --git a/test/files/jvm/methvsfield.java b/test/files/jvm/methvsfield.java
index c1b2b87b48..dadc98669a 100644
--- a/test/files/jvm/methvsfield.java
+++ b/test/files/jvm/methvsfield.java
@@ -1,11 +1,11 @@
// This should be compiled with javac and saved
// in ../lib/methvsfield.jar .
-class MethVsField
+class MethVsField
{
int three = 3;
- int three()
- {
+ int three()
+ {
return 3;
}
}
diff --git a/test/files/jvm/named-args-in-order.check b/test/files/jvm/named-args-in-order.check
new file mode 100644
index 0000000000..29a3ba55d3
--- /dev/null
+++ b/test/files/jvm/named-args-in-order.check
@@ -0,0 +1,3 @@
+bytecode identical
+bytecode identical
+bytecode identical
diff --git a/test/files/jvm/named-args-in-order/SameBytecode.scala b/test/files/jvm/named-args-in-order/SameBytecode.scala
new file mode 100644
index 0000000000..c00641777e
--- /dev/null
+++ b/test/files/jvm/named-args-in-order/SameBytecode.scala
@@ -0,0 +1,9 @@
+class SameBytecode {
+ def foo(a: Int, b: String) = 0
+ def foo(a: Int, b: Any) = 0
+
+ def a = foo(0, "")
+ def b = foo(a = 0, "")
+ def c = foo(0, b = "")
+ def d = foo(a = 0, b = "")
+} \ No newline at end of file
diff --git a/test/files/jvm/named-args-in-order/Test.scala b/test/files/jvm/named-args-in-order/Test.scala
new file mode 100644
index 0000000000..36b9cbc1d1
--- /dev/null
+++ b/test/files/jvm/named-args-in-order/Test.scala
@@ -0,0 +1,10 @@
+import scala.tools.partest.BytecodeTest
+
+object Test extends BytecodeTest {
+ def show: Unit = {
+ val classNode = loadClassNode("SameBytecode")
+ def sameAsA(meth: String) =
+ sameBytecode(getMethod(classNode, "a"), getMethod(classNode, meth))
+ Seq("b", "c", "d").foreach(sameAsA)
+ }
+}
diff --git a/test/files/jvm/natives.scala b/test/files/jvm/natives.scala
index ba868dc85e..14ee4e1c1b 100644
--- a/test/files/jvm/natives.scala
+++ b/test/files/jvm/natives.scala
@@ -1,16 +1,16 @@
object Test {
//println("java.library.path=" + System.getProperty("java.library.path"))
-
+
val sysWordSize = System.getProperty("sun.arch.data.model", "32")
val sysType = System.getProperty("os.name")
-
+
val libName =
if (sysType == "Mac OS X")
"natives"
else
"natives-" + sysWordSize
-
+
System.loadLibrary(libName)
@native
diff --git a/test/files/jvm/non-fatal-tests.scala b/test/files/jvm/non-fatal-tests.scala
index 471a9d227a..1ff7ee516e 100644
--- a/test/files/jvm/non-fatal-tests.scala
+++ b/test/files/jvm/non-fatal-tests.scala
@@ -4,19 +4,19 @@ trait NonFatalTests {
//NonFatals
val nonFatals: Seq[Throwable] =
- Seq(new StackOverflowError,
- new RuntimeException,
+ Seq(new RuntimeException,
new Exception,
- new Throwable)
-
+ new Throwable,
+ new NotImplementedError)
+
//Fatals
val fatals: Seq[Throwable] =
Seq(new InterruptedException,
+ new StackOverflowError,
new OutOfMemoryError,
new LinkageError,
new VirtualMachineError {},
- new Throwable with scala.util.control.ControlThrowable,
- new NotImplementedError)
+ new Throwable with scala.util.control.ControlThrowable)
def testFatalsUsingApply(): Unit = {
fatals foreach { t => assert(NonFatal(t) == false) }
diff --git a/test/files/jvm/nooptimise/Foo_1.flags b/test/files/jvm/nooptimise/Foo_1.flags
new file mode 100644
index 0000000000..f493cf9f3f
--- /dev/null
+++ b/test/files/jvm/nooptimise/Foo_1.flags
@@ -0,0 +1 @@
+-Ybackend:GenASM -optimise -Ynooptimise \ No newline at end of file
diff --git a/test/files/jvm/nooptimise/Foo_1.scala b/test/files/jvm/nooptimise/Foo_1.scala
new file mode 100644
index 0000000000..896d5695de
--- /dev/null
+++ b/test/files/jvm/nooptimise/Foo_1.scala
@@ -0,0 +1,8 @@
+class Foo_1 {
+ def foo() {
+ // optimization will remove this magic 3 from appearing in the source
+ // so -Ynooptimize should prevent that
+ val x = 3
+
+ }
+}
diff --git a/test/files/jvm/nooptimise/Test.scala b/test/files/jvm/nooptimise/Test.scala
new file mode 100644
index 0000000000..7b7ecd6dbd
--- /dev/null
+++ b/test/files/jvm/nooptimise/Test.scala
@@ -0,0 +1,23 @@
+import scala.tools.partest.BytecodeTest
+import scala.tools.asm
+import asm.tree.InsnList
+import scala.collection.JavaConverters._
+
+object Test extends BytecodeTest {
+ def show: Unit = {
+ val classNode = loadClassNode("Foo_1")
+ val methodNode = getMethod(classNode, "foo")
+ // if optimization didn't run then
+ // there should be some useless instructions
+ // with the magic constant 3
+ val expected = 1
+ val got = countMagicThrees(methodNode.instructions)
+ assert(got == expected, s"expected $expected but got $got magic threes")
+ }
+
+ def countMagicThrees(insnList: InsnList): Int = {
+ def isMagicThree(node: asm.tree.AbstractInsnNode): Boolean =
+ (node.getOpcode == asm.Opcodes.ICONST_3)
+ insnList.iterator.asScala.count(isMagicThree)
+ }
+}
diff --git a/test/files/jvm/opt_value_class.check b/test/files/jvm/opt_value_class.check
new file mode 100644
index 0000000000..a0c18c5ca0
--- /dev/null
+++ b/test/files/jvm/opt_value_class.check
@@ -0,0 +1,2 @@
+[ok] <init> ()V public
+[ok] unapply (Ljava/lang/Object;)Ljava/lang/String; public (Ljava/lang/Object;)Ljava/lang/String;
diff --git a/test/files/jvm/opt_value_class/Value_1.scala b/test/files/jvm/opt_value_class/Value_1.scala
new file mode 100644
index 0000000000..2440609b9e
--- /dev/null
+++ b/test/files/jvm/opt_value_class/Value_1.scala
@@ -0,0 +1,28 @@
+final class Opt[+A >: Null](val value: A) extends AnyVal {
+ def get: A = value
+ def isEmpty = value == null
+}
+object Opt {
+ final val None = new Opt[Null](null)
+ def unapply[A >: Null](x: A): Opt[A] = if (x == null) None else Opt(x)
+ def empty[A >: Null] = None
+ def apply[A >: Null](value: A): Opt[A] = if (value == null) None else new Opt[A](value)
+}
+
+class ValueExtract {
+ def unapply(x: Any): Opt[String] = x match {
+ case _: String => Opt("String")
+ case _: List[_] => Opt("List")
+ case _: Int => Opt("Int")
+ case _ => Opt.None
+ }
+}
+
+class Direct {
+ def unapply(x: Any): String = x match {
+ case _: String => "String"
+ case _: List[_] => "List"
+ case _: Int => "Int"
+ case _ => null
+ }
+}
diff --git a/test/files/jvm/opt_value_class/test.scala b/test/files/jvm/opt_value_class/test.scala
new file mode 100644
index 0000000000..7aea7deb99
--- /dev/null
+++ b/test/files/jvm/opt_value_class/test.scala
@@ -0,0 +1,16 @@
+import scala.tools.partest.BytecodeTest
+
+// import scala.tools.nsc.util.JavaClassPath
+// import java.io.InputStream
+// import scala.tools.asm
+// import asm.ClassReader
+// import asm.tree.{ClassNode, InsnList}
+// import scala.collection.JavaConverters._
+
+object Test extends BytecodeTest {
+ def show: Unit = {
+ val classNode1 = loadClassNode("ValueExtract")
+ val classNode2 = loadClassNode("Direct")
+ sameMethodAndFieldDescriptors(classNode1, classNode2)
+ }
+}
diff --git a/test/files/jvm/patmat_opt_ignore_underscore/Analyzed_1.scala b/test/files/jvm/patmat_opt_ignore_underscore/Analyzed_1.scala
index fa3639380d..b0506018f6 100644
--- a/test/files/jvm/patmat_opt_ignore_underscore/Analyzed_1.scala
+++ b/test/files/jvm/patmat_opt_ignore_underscore/Analyzed_1.scala
@@ -6,7 +6,7 @@
class SameBytecode {
case class Foo(x: Any, y: String)
- def a =
+ def a =
Foo(1, "a") match {
case Foo(_: String, y) => y
}
diff --git a/test/files/jvm/patmat_opt_no_nullcheck/Analyzed_1.scala b/test/files/jvm/patmat_opt_no_nullcheck/Analyzed_1.scala
index 3a594c401e..1e4d564cdf 100644
--- a/test/files/jvm/patmat_opt_no_nullcheck/Analyzed_1.scala
+++ b/test/files/jvm/patmat_opt_no_nullcheck/Analyzed_1.scala
@@ -3,7 +3,7 @@
case class Foo(x: Any)
class SameBytecode {
- def a =
+ def a =
(Foo(1): Any) match {
case Foo(_: String) =>
}
diff --git a/test/files/jvm/patmat_opt_primitive_typetest/Analyzed_1.scala b/test/files/jvm/patmat_opt_primitive_typetest/Analyzed_1.scala
index e5db6c4dd0..c961082fa7 100644
--- a/test/files/jvm/patmat_opt_primitive_typetest/Analyzed_1.scala
+++ b/test/files/jvm/patmat_opt_primitive_typetest/Analyzed_1.scala
@@ -3,7 +3,7 @@
class SameBytecode {
case class Foo(x: Int, y: String)
- def a =
+ def a =
Foo(1, "a") match {
case Foo(_: Int, y) => y
}
diff --git a/test/files/jvm/protectedacc.scala b/test/files/jvm/protectedacc.scala
index f213e0da19..89e70b90d8 100644
--- a/test/files/jvm/protectedacc.scala
+++ b/test/files/jvm/protectedacc.scala
@@ -16,7 +16,7 @@ object Test {
val ji = new p.b.JavaInteraction(Array('a', 'b', 'c'));
(new ji.Inner).m;
-
+
(new p.b.OuterObj.Inner).m
}
}
@@ -36,13 +36,13 @@ package p {
def getA: this.type = this;
}
-
+
/** Test type members */
trait HighlighterXXX {
type Node;
protected def highlight(node : Node) : Unit;
}
-
+
/** Test type parameters */
abstract class PolyA[a] {
protected def m(x: a): Unit;
@@ -119,22 +119,22 @@ package p {
val inc = meth2(1)_;
Console.println("100 = " + inc("10"));
-
+
getA.x;
}
}
}
-
+
trait ScalaAutoEditXXX extends HighlighterXXX {
- trait NodeImpl {
+ trait NodeImpl {
def self : Node;
highlight(self);
}
}
-
+
abstract class X[T] extends PolyA[T] {
- trait Inner extends B {
+ trait Inner extends B {
def self: T;
def self2: Node;
def getB: Inner;
diff --git a/test/files/jvm/reactor-exceptionOnSend.scala b/test/files/jvm/reactor-exceptionOnSend.scala
index 3d9a042131..6d79fc9d13 100644
--- a/test/files/jvm/reactor-exceptionOnSend.scala
+++ b/test/files/jvm/reactor-exceptionOnSend.scala
@@ -1,3 +1,7 @@
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.Reactor
import scala.actors.Actor._
@@ -48,7 +52,6 @@ object B extends Reactor[Any] {
}
}
-object Test {
def main(args: Array[String]) {
B.start()
}
diff --git a/test/files/jvm/reactor-producer-consumer.scala b/test/files/jvm/reactor-producer-consumer.scala
index 8a6b17c3ad..ec34febe01 100644
--- a/test/files/jvm/reactor-producer-consumer.scala
+++ b/test/files/jvm/reactor-producer-consumer.scala
@@ -1,6 +1,8 @@
-import scala.actors.Reactor
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.Reactor
case class Stop()
case class Get(from: Reactor[Any])
case class Put(x: Int)
diff --git a/test/files/jvm/reactor.scala b/test/files/jvm/reactor.scala
index dbc9a6bdda..91ded27f07 100644
--- a/test/files/jvm/reactor.scala
+++ b/test/files/jvm/reactor.scala
@@ -1,3 +1,11 @@
+/**
+ * Ping pong example for Reactor.
+ *
+ * @author Philipp Haller
+ */
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.Reactor
@@ -5,19 +13,12 @@ case class Ping(from: Reactor[Any])
case object Pong
case object Stop
-/**
- * Ping pong example for Reactor.
- *
- * @author Philipp Haller
- */
-object Test {
def main(args: Array[String]) {
val pong = new PongActor
val ping = new PingActor(100000, pong)
ping.start
pong.start
}
-}
class PingActor(count: Int, pong: Reactor[Any]) extends Reactor[Any] {
def act() {
@@ -68,3 +69,4 @@ class PongActor extends Reactor[Any] {
}
}
}
+}
diff --git a/test/files/jvm/replyablereactor.scala b/test/files/jvm/replyablereactor.scala
index e1fabc98da..4c4e13d9ab 100644
--- a/test/files/jvm/replyablereactor.scala
+++ b/test/files/jvm/replyablereactor.scala
@@ -1,3 +1,7 @@
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.ReplyReactor
class MyActor extends ReplyReactor {
@@ -18,7 +22,6 @@ class MyActor extends ReplyReactor {
}
}
-object Test {
def main(args: Array[String]) {
val a = new MyActor
a.start()
diff --git a/test/files/jvm/replyablereactor2.scala b/test/files/jvm/replyablereactor2.scala
index da9e0e269e..21f33cce56 100644
--- a/test/files/jvm/replyablereactor2.scala
+++ b/test/files/jvm/replyablereactor2.scala
@@ -1,3 +1,7 @@
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors._
import scala.actors.Actor._
@@ -19,7 +23,6 @@ class MyActor extends ReplyReactor {
}
}
-object Test {
def main(args: Array[String]) {
val a = new MyActor
a.start()
diff --git a/test/files/jvm/replyablereactor3.scala b/test/files/jvm/replyablereactor3.scala
index 2c26b8a176..5810ed053f 100644
--- a/test/files/jvm/replyablereactor3.scala
+++ b/test/files/jvm/replyablereactor3.scala
@@ -1,3 +1,7 @@
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors._
import scala.actors.Actor._
@@ -19,7 +23,6 @@ class MyActor extends ReplyReactor {
}
}
-object Test {
def main(args: Array[String]) {
val a = new MyActor
a.start()
diff --git a/test/files/jvm/replyablereactor4.scala b/test/files/jvm/replyablereactor4.scala
index 8776cf63f0..95d63684dd 100644
--- a/test/files/jvm/replyablereactor4.scala
+++ b/test/files/jvm/replyablereactor4.scala
@@ -1,3 +1,7 @@
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors._
import scala.actors.Actor._
@@ -19,7 +23,6 @@ class MyActor extends ReplyReactor {
}
}
-object Test {
def main(args: Array[String]) {
val a = new MyActor
a.start()
diff --git a/test/files/jvm/replyreactor-react-sender.scala b/test/files/jvm/replyreactor-react-sender.scala
index c9884295f6..fdcea09035 100644
--- a/test/files/jvm/replyreactor-react-sender.scala
+++ b/test/files/jvm/replyreactor-react-sender.scala
@@ -1,7 +1,9 @@
-import scala.actors.ReplyReactor
-import scala.actors.Actor._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.ReplyReactor
+ import scala.actors.Actor._
val NUM = 2000
diff --git a/test/files/jvm/replyreactor.scala b/test/files/jvm/replyreactor.scala
index 0cecf29ec7..7512fb0eb2 100644
--- a/test/files/jvm/replyreactor.scala
+++ b/test/files/jvm/replyreactor.scala
@@ -1,6 +1,8 @@
-import scala.actors.ReplyReactor
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.ReplyReactor
def main(args: Array[String]) {
val a = new ReplyReactor {
def act() {
diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala
index a306a7d15b..ce86d4aef0 100644
--- a/test/files/jvm/scala-concurrent-tck.scala
+++ b/test/files/jvm/scala-concurrent-tck.scala
@@ -8,7 +8,7 @@ import scala.concurrent.{
CanAwait,
Await
}
-import scala.concurrent.{ future, promise, blocking }
+import scala.concurrent.blocking
import scala.util.{ Try, Success, Failure }
import scala.concurrent.duration.Duration
import scala.reflect.{ classTag, ClassTag }
@@ -35,15 +35,15 @@ trait FutureCallbacks extends TestBase {
def testOnSuccess(): Unit = once {
done =>
var x = 0
- val f = future { 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 }
- f onSuccess {
+ val f = Future { x = 1 }
+ f onSuccess {
case _ if x == 1 =>
x = 2
f onSuccess { case _ => done(x == 2) }
@@ -52,31 +52,31 @@ trait FutureCallbacks extends TestBase {
def testOnSuccessWhenFailed(): Unit = once {
done =>
- val f = future[Unit] { throw new Exception }
+ val f = Future[Unit] { throw new Exception }
f onSuccess { case _ => done(false) }
f onFailure { case _ => done(true) }
}
-
+
def testOnFailure(): Unit = once {
done =>
- val f = future[Unit] { throw new Exception }
+ 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 }
+ val f = Future[Unit] { throw cause }
f onSuccess { case _ => done(false) }
f onFailure {
case e: ExecutionException if e.getCause == cause => done(true)
case _ => done(false)
}
}
-
+
def testOnFailureWhenTimeoutException(): Unit = once {
done =>
- val f = future[Unit] { throw new TimeoutException() }
+ val f = Future[Unit] { throw new TimeoutException() }
f onSuccess { case _ => done(false) }
f onFailure {
case e: TimeoutException => done(true)
@@ -89,7 +89,7 @@ trait FutureCallbacks extends TestBase {
(0 to 10000).map(Future(_)).foldLeft(promise.future)((f1, f2) => f2.flatMap(i => f1))
promise.success(-1)
}
-
+
testOnSuccess()
testOnSuccessWhenCompleted()
testOnSuccessWhenFailed()
@@ -108,7 +108,7 @@ trait FutureCombinators extends TestBase {
def testMapSuccess(): Unit = once {
done =>
- val f = future { 5 }
+ val f = Future { 5 }
val g = f map { x => "result: " + x }
g onSuccess { case s => done(s == "result: 5") }
g onFailure { case _ => done(false) }
@@ -116,7 +116,7 @@ trait FutureCombinators extends TestBase {
def testMapFailure(): Unit = once {
done =>
- val f = future[Unit] { 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(false) }
g onFailure { case t => done(t.getMessage() == "exception message") }
@@ -124,7 +124,7 @@ trait FutureCombinators extends TestBase {
def testMapSuccessPF(): Unit = once {
done =>
- val f = future { 5 }
+ val f = Future { 5 }
val g = f map { case r => "result: " + r }
g onSuccess { case s => done(s == "result: 5") }
g onFailure { case _ => done(false) }
@@ -132,7 +132,7 @@ trait FutureCombinators extends TestBase {
def testTransformSuccess(): Unit = once {
done =>
- val f = future { 5 }
+ val f = Future { 5 }
val g = f.transform(r => "result: " + r, identity)
g onSuccess { case s => done(s == "result: 5") }
g onFailure { case _ => done(false) }
@@ -140,7 +140,7 @@ trait FutureCombinators extends TestBase {
def testTransformSuccessPF(): Unit = once {
done =>
- val f = future { 5 }
+ val f = Future { 5 }
val g = f.transform( { case r => "result: " + r }, identity)
g onSuccess { case s => done(s == "result: 5") }
g onFailure { case _ => done(false) }
@@ -149,7 +149,7 @@ trait FutureCombinators extends TestBase {
def testTransformFailure(): Unit = once {
done =>
val transformed = new Exception("transformed")
- val f = future { throw new Exception("expected") }
+ 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) }
@@ -159,7 +159,7 @@ def testTransformFailure(): Unit = once {
done =>
val e = new Exception("expected")
val transformed = new Exception("transformed")
- val f = future[Unit] { throw e }
+ 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) }
@@ -167,7 +167,7 @@ def testTransformFailure(): Unit = once {
def testFoldFailure(): Unit = once {
done =>
- val f = future[Unit] { throw new Exception("expected") }
+ val f = Future[Unit] { throw new Exception("expected") }
val g = f.transform(r => "result: " + r, identity)
g onSuccess { case _ => done(false) }
g onFailure { case t => done(t.getMessage() == "expected") }
@@ -175,23 +175,23 @@ def testTransformFailure(): Unit = once {
def testFlatMapSuccess(): Unit = once {
done =>
- val f = future { 5 }
- val g = f flatMap { _ => future { 10 } }
+ val f = Future { 5 }
+ val g = f flatMap { _ => Future { 10 } }
g onSuccess { case x => done(x == 10) }
g onFailure { case _ => done(false) }
}
def testFlatMapFailure(): Unit = once {
done =>
- val f = future[Unit] { throw new Exception("expected") }
- val g = f flatMap { _ => future { 10 } }
+ val f = Future[Unit] { throw new Exception("expected") }
+ val g = f flatMap { _ => Future { 10 } }
g onSuccess { case _ => done(false) }
g onFailure { case t => done(t.getMessage() == "expected") }
}
def testFilterSuccess(): Unit = once {
done =>
- val f = future { 4 }
+ val f = Future { 4 }
val g = f filter { _ % 2 == 0 }
g onSuccess { case x: Int => done(x == 4) }
g onFailure { case _ => done(false) }
@@ -199,7 +199,7 @@ def testTransformFailure(): Unit = once {
def testFilterFailure(): Unit = once {
done =>
- val f = future { 4 }
+ val f = Future { 4 }
val g = f filter { _ % 2 == 1 }
g onSuccess { case x: Int => done(false) }
g onFailure {
@@ -210,7 +210,7 @@ def testTransformFailure(): Unit = once {
def testCollectSuccess(): Unit = once {
done =>
- val f = future { -5 }
+ val f = Future { -5 }
val g = f collect { case x if x < 0 => -x }
g onSuccess { case x: Int => done(x == 5) }
g onFailure { case _ => done(false) }
@@ -218,7 +218,7 @@ def testTransformFailure(): Unit = once {
def testCollectFailure(): Unit = once {
done =>
- val f = future { -5 }
+ val f = Future { -5 }
val g = f collect { case x if x > 0 => x * 2 }
g onSuccess { case _ => done(false) }
g onFailure {
@@ -232,23 +232,23 @@ def testTransformFailure(): Unit = once {
def testForeachSuccess(): Unit = once {
done =>
- val p = promise[Int]()
- val f = future[Int] { 5 }
+ val p = Promise[Int]()
+ val f = Future[Int] { 5 }
f foreach { x => p.success(x * 2) }
val g = p.future
-
+
g.onSuccess { case res: Int => done(res == 10) }
g.onFailure { case _ => done(false) }
}
def testForeachFailure(): Unit = once {
done =>
- val p = promise[Int]()
- val f = future[Int] { throw new Exception }
+ val p = Promise[Int]()
+ val f = Future[Int] { throw new Exception }
f foreach { x => p.success(x * 2) }
f onFailure { case _ => p.failure(new Exception) }
val g = p.future
-
+
g.onSuccess { case _ => done(false) }
g.onFailure { case _ => done(true) }
}
@@ -256,7 +256,7 @@ def testTransformFailure(): Unit = once {
def testRecoverSuccess(): Unit = once {
done =>
val cause = new RuntimeException
- val f = future {
+ val f = Future {
throw cause
} recover {
case re: RuntimeException =>
@@ -268,7 +268,7 @@ def testTransformFailure(): Unit = once {
def testRecoverFailure(): Unit = once {
done =>
val cause = new RuntimeException
- val f = future {
+ val f = Future {
throw cause
} recover {
case te: TimeoutException => "timeout"
@@ -276,15 +276,15 @@ def testTransformFailure(): Unit = once {
f onSuccess { case _ => done(false) }
f onFailure { case any => done(any == cause) }
}
-
+
def testRecoverWithSuccess(): Unit = once {
done =>
val cause = new RuntimeException
- val f = future {
+ val f = Future {
throw cause
} recoverWith {
case re: RuntimeException =>
- future { "recovered" }
+ Future { "recovered" }
}
f onSuccess { case x => done(x == "recovered") }
f onFailure { case any => done(false) }
@@ -293,20 +293,20 @@ def testTransformFailure(): Unit = once {
def testRecoverWithFailure(): Unit = once {
done =>
val cause = new RuntimeException
- val f = future {
+ val f = Future {
throw cause
} recoverWith {
case te: TimeoutException =>
- future { "timeout" }
+ Future { "timeout" }
}
f onSuccess { case x => done(false) }
f onFailure { case any => done(any == cause) }
}
-
+
def testZipSuccess(): Unit = once {
done =>
- val f = future { 5 }
- val g = future { 6 }
+ val f = Future { 5 }
+ val g = Future { 6 }
val h = f zip g
h onSuccess { case (l: Int, r: Int) => done(l+r == 11) }
h onFailure { case _ => done(false) }
@@ -315,8 +315,8 @@ def testTransformFailure(): Unit = once {
def testZipFailureLeft(): Unit = once {
done =>
val cause = new Exception("expected")
- val f = future { throw cause }
- val g = future { 6 }
+ val f = Future { throw cause }
+ val g = Future { 6 }
val h = f zip g
h onSuccess { case _ => done(false) }
h onFailure { case e: Exception => done(e.getMessage == "expected") }
@@ -325,8 +325,8 @@ def testTransformFailure(): Unit = once {
def testZipFailureRight(): Unit = once {
done =>
val cause = new Exception("expected")
- val f = future { 5 }
- val g = future { throw cause }
+ val f = Future { 5 }
+ val g = Future { throw cause }
val h = f zip g
h onSuccess { case _ => done(false) }
h onFailure { case e: Exception => done(e.getMessage == "expected") }
@@ -334,8 +334,8 @@ def testTransformFailure(): Unit = once {
def testFallbackTo(): Unit = once {
done =>
- val f = future { sys.error("failed") }
- val g = future { 5 }
+ val f = Future { sys.error("failed") }
+ val g = Future { 5 }
val h = f fallbackTo g
h onSuccess { case x: Int => done(x == 5) }
h onFailure { case _ => done(false) }
@@ -344,8 +344,8 @@ def testTransformFailure(): Unit = once {
def testFallbackToFailure(): Unit = once {
done =>
val cause = new Exception
- val f = future { throw cause }
- val g = future { sys.error("failed") }
+ val f = Future { throw cause }
+ val g = Future { sys.error("failed") }
val h = f fallbackTo g
h onSuccess { case _ => done(false) }
@@ -382,49 +382,49 @@ 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) => done(t == cause)
case Failure(t) => done(false)
}
}
-
+
def testFailedFailureOnSuccess(): Unit = once {
done =>
val cause = new RuntimeException
- val f = future { throw cause }
+ val f = Future { throw cause }
f.failed onSuccess { case t => done(t == cause) }
}
-
+
def testFailedSuccessOnComplete(): Unit = once {
done =>
- val f = future { 0 }
+ val f = Future { 0 }
f.failed onComplete {
case Failure(_: NoSuchElementException) => done(true)
case _ => done(false)
}
}
-
+
def testFailedSuccessOnFailure(): Unit = once {
done =>
- val f = future { 0 }
+ val f = Future { 0 }
f.failed onFailure {
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 }
+ val f = Future { throw cause }
done(Await.result(f.failed, Duration(500, "ms")) == cause)
}
-
+
def testFailedSuccessAwait(): Unit = once {
done =>
- val f = future { 0 }
+ val f = Future { 0 }
try {
Await.result(f.failed, Duration(500, "ms"))
done(false)
@@ -437,7 +437,7 @@ trait FutureProjections extends TestBase {
def testAwaitPositiveDuration(): Unit = once { done =>
val p = Promise[Int]()
val f = p.future
- future {
+ Future {
intercept[IllegalArgumentException] { Await.ready(f, Duration.Undefined) }
p.success(0)
Await.ready(f, Duration.Zero)
@@ -449,14 +449,14 @@ trait FutureProjections extends TestBase {
def testAwaitNegativeDuration(): Unit = once { done =>
val f = Promise().future
- future {
+ Future {
intercept[TimeoutException] { Await.ready(f, Duration.Zero) }
intercept[TimeoutException] { Await.ready(f, Duration.MinusInf) }
intercept[TimeoutException] { Await.ready(f, Duration(-500, "ms")) }
done(true)
} onFailure { case x => done(throw x) }
}
-
+
testFailedFailureOnComplete()
testFailedFailureOnSuccess()
testFailedSuccessOnComplete()
@@ -473,14 +473,14 @@ trait Blocking extends TestBase {
def testAwaitSuccess(): Unit = once {
done =>
- val f = future { 0 }
+ val f = Future { 0 }
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"))
done(false)
@@ -488,13 +488,13 @@ trait Blocking extends TestBase {
case t: Throwable => done(t == cause)
}
}
-
+
def testFQCNForAwaitAPI(): Unit = once {
done =>
- done(classOf[CanAwait].getName == "scala.concurrent.CanAwait" &&
+ done(classOf[CanAwait].getName == "scala.concurrent.CanAwait" &&
Await.getClass.getName == "scala.concurrent.Await")
}
-
+
testAwaitSuccess()
testAwaitFailure()
testFQCNForAwaitAPI()
@@ -562,24 +562,24 @@ trait Promises extends TestBase {
def testSuccess(): Unit = once {
done =>
- val p = promise[Int]()
+ val p = Promise[Int]()
val f = p.future
-
+
f onSuccess { case x => done(x == 5) }
f onFailure { case any => done(false) }
-
+
p.success(5)
}
def testFailure(): Unit = once {
done =>
val e = new Exception("expected")
- val p = promise[Int]()
+ 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)
}
@@ -644,7 +644,7 @@ 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()
@@ -715,13 +715,13 @@ trait ExecutionContextPrepare extends TestBase {
val theLocal = new ThreadLocal[String] {
override protected def initialValue(): String = ""
}
-
+
class PreparingExecutionContext extends ExecutionContext {
def delegate = ExecutionContext.global
-
+
override def execute(runnable: Runnable): Unit =
delegate.execute(runnable)
-
+
override def prepare(): ExecutionContext = {
// save object stored in ThreadLocal storage
val localData = theLocal.get
@@ -739,27 +739,27 @@ trait ExecutionContextPrepare extends TestBase {
}
}
}
-
+
override def reportFailure(t: Throwable): Unit =
delegate.reportFailure(t)
}
-
+
implicit val ec = new PreparingExecutionContext
-
+
def testOnComplete(): Unit = once {
done =>
theLocal.set("secret")
- val fut = future { 42 }
+ val fut = Future { 42 }
fut onComplete { case _ => done(theLocal.get == "secret") }
}
-
+
def testMap(): Unit = once {
done =>
theLocal.set("secret2")
- val fut = future { 42 }
+ val fut = Future { 42 }
fut map { x => done(theLocal.get == "secret2") }
}
-
+
testOnComplete()
testMap()
}
diff --git a/test/files/jvm/scheduler-adapter.scala b/test/files/jvm/scheduler-adapter.scala
index d6a8a446a0..1c9cfe7019 100644
--- a/test/files/jvm/scheduler-adapter.scala
+++ b/test/files/jvm/scheduler-adapter.scala
@@ -1,3 +1,7 @@
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.{Actor, SchedulerAdapter}
trait AdaptedActor extends Actor {
@@ -36,7 +40,6 @@ object Two extends AdaptedActor {
}
}
-object Test {
val adapted =
new SchedulerAdapter {
def execute(block: => Unit) {
diff --git a/test/files/jvm/serialization-new.check b/test/files/jvm/serialization-new.check
index f886cfe29c..47d7bfd920 100644
--- a/test/files/jvm/serialization-new.check
+++ b/test/files/jvm/serialization-new.check
@@ -1,3 +1,4 @@
+warning: there were 2 deprecation warning(s); re-run with -deprecation for details
a1 = Array[1,2,3]
_a1 = Array[1,2,3]
arrayEquals(a1, _a1): true
@@ -220,60 +221,6 @@ x = TrieMap(1 -> one, 2 -> two, 3 -> three)
y = TrieMap(1 -> one, 2 -> two, 3 -> three)
x equals y: true, y equals x: true
-x = xml:src="hello"
-y = xml:src="hello"
-x equals y: true, y equals x: true
-
-x = <title></title>
-y = <title></title>
-x equals y: true, y equals x: true
-
-x = <html><title>title</title><body></body></html>
-y = <html><title>title</title><body></body></html>
-x equals y: true, y equals x: true
-
-x = <html>
- <body>
- <table cellpadding="2" cellspacing="0">
- <tr>
- <th>Last Name</th>
- <th>First Name</th>
- </tr>
- <tr>
- <td> Tom </td>
- <td> 20 </td>
- </tr><tr>
- <td> Bob </td>
- <td> 22 </td>
- </tr><tr>
- <td> James </td>
- <td> 19 </td>
- </tr>
- </table>
- </body>
- </html>
-y = <html>
- <body>
- <table cellpadding="2" cellspacing="0">
- <tr>
- <th>Last Name</th>
- <th>First Name</th>
- </tr>
- <tr>
- <td> Tom </td>
- <td> 20 </td>
- </tr><tr>
- <td> Bob </td>
- <td> 22 </td>
- </tr><tr>
- <td> James </td>
- <td> 19 </td>
- </tr>
- </table>
- </body>
- </html>
-x equals y: true, y equals x: true
-
x = Tim
y = Tim
x equals y: true, y equals x: true
diff --git a/test/files/jvm/serialization-new.scala b/test/files/jvm/serialization-new.scala
index 1522fc8e27..1b5e856645 100644
--- a/test/files/jvm/serialization-new.scala
+++ b/test/files/jvm/serialization-new.scala
@@ -419,70 +419,6 @@ object Test3_mutable {
}
}
-
-//############################################################################
-// Test classes in package "scala.xml"
-
-object Test4_xml {
- import scala.xml.{Attribute, Document, Elem, Null, PrefixedAttribute, Text}
-
- case class Person(name: String, age: Int)
-
- try {
- // Attribute
- val a1 = new PrefixedAttribute("xml", "src", Text("hello"), Null)
- val _a1: Attribute = read(write(a1))
- check(a1, _a1)
-
- // Document
- val d1 = new Document
- d1.docElem = <title></title>
- d1.encoding = Some("UTF-8")
- val _d1: Document = read(write(d1))
- check(d1, _d1)
-
- // Elem
- val e1 = <html><title>title</title><body></body></html>;
- val _e1: Elem = read(write(e1))
- check(e1, _e1)
-
- class AddressBook(a: Person*) {
- private val people: List[Person] = a.toList
- def toXHTML =
- <table cellpadding="2" cellspacing="0">
- <tr>
- <th>Last Name</th>
- <th>First Name</th>
- </tr>
- { for (p <- people) yield
- <tr>
- <td> { p.name } </td>
- <td> { p.age.toString() } </td>
- </tr> }
- </table>;
- }
-
- val people = new AddressBook(
- Person("Tom", 20),
- Person("Bob", 22),
- Person("James", 19))
-
- val e2 =
- <html>
- <body>
- { people.toXHTML }
- </body>
- </html>;
- val _e2: Elem = read(write(e2))
- check(e2, _e2)
- }
- catch {
- case e: Exception =>
- println("Error in Test4_xml: " + e)
- throw e
- }
-}
-
//############################################################################
// Test user-defined classes WITHOUT nesting
@@ -594,11 +530,10 @@ object Test8 {
// Test code
object Test {
- def main(args: Array[String]) {
+ def main(args: Array[String]): Unit = {
Test1_scala
Test2_immutable
Test3_mutable
- Test4_xml
Test5
Test6
Test7
diff --git a/test/files/jvm/serialization.check b/test/files/jvm/serialization.check
index f886cfe29c..47d7bfd920 100644
--- a/test/files/jvm/serialization.check
+++ b/test/files/jvm/serialization.check
@@ -1,3 +1,4 @@
+warning: there were 2 deprecation warning(s); re-run with -deprecation for details
a1 = Array[1,2,3]
_a1 = Array[1,2,3]
arrayEquals(a1, _a1): true
@@ -220,60 +221,6 @@ x = TrieMap(1 -> one, 2 -> two, 3 -> three)
y = TrieMap(1 -> one, 2 -> two, 3 -> three)
x equals y: true, y equals x: true
-x = xml:src="hello"
-y = xml:src="hello"
-x equals y: true, y equals x: true
-
-x = <title></title>
-y = <title></title>
-x equals y: true, y equals x: true
-
-x = <html><title>title</title><body></body></html>
-y = <html><title>title</title><body></body></html>
-x equals y: true, y equals x: true
-
-x = <html>
- <body>
- <table cellpadding="2" cellspacing="0">
- <tr>
- <th>Last Name</th>
- <th>First Name</th>
- </tr>
- <tr>
- <td> Tom </td>
- <td> 20 </td>
- </tr><tr>
- <td> Bob </td>
- <td> 22 </td>
- </tr><tr>
- <td> James </td>
- <td> 19 </td>
- </tr>
- </table>
- </body>
- </html>
-y = <html>
- <body>
- <table cellpadding="2" cellspacing="0">
- <tr>
- <th>Last Name</th>
- <th>First Name</th>
- </tr>
- <tr>
- <td> Tom </td>
- <td> 20 </td>
- </tr><tr>
- <td> Bob </td>
- <td> 22 </td>
- </tr><tr>
- <td> James </td>
- <td> 19 </td>
- </tr>
- </table>
- </body>
- </html>
-x equals y: true, y equals x: true
-
x = Tim
y = Tim
x equals y: true, y equals x: true
diff --git a/test/files/jvm/serialization.scala b/test/files/jvm/serialization.scala
index 34b64938b4..bc61235267 100644
--- a/test/files/jvm/serialization.scala
+++ b/test/files/jvm/serialization.scala
@@ -281,6 +281,7 @@ object Test2_immutable {
//############################################################################
// Test classes in package "scala.collection.mutable"
+@deprecated("Suppress warnings", since="2.11")
object Test3_mutable {
import scala.reflect.ClassManifest
import scala.collection.mutable.{
@@ -296,7 +297,7 @@ object Test3_mutable {
ab1 ++= List("one", "two")
val _ab1: ArrayBuffer[String] = read(write(ab1))
check(ab1, _ab1)
-
+
// ArrayBuilder
val abu1 = ArrayBuilder.make[Long]
val _abu1: ArrayBuilder[ClassManifest[Long]] = read(write(abu1))
@@ -305,12 +306,12 @@ object Test3_mutable {
val abu2 = ArrayBuilder.make[Float]
val _abu2: ArrayBuilder[ClassManifest[Float]] = read(write(abu2))
check(abu2, _abu2)
-
+
// ArraySeq
val aq1 = ArraySeq(1, 2, 3)
val _aq1: ArraySeq[Int] = read(write(aq1))
check(aq1, _aq1)
-
+
// ArrayStack
val as1 = new ArrayStack[Int]
as1 ++= List(20, 2, 3).iterator
@@ -401,12 +402,12 @@ object Test3_mutable {
val wa1 = WrappedArray.make(Array(1, 2, 3))
val _wa1: WrappedArray[Int] = read(write(wa1))
check(wa1, _wa1)
-
+
// TreeSet
val ts1 = TreeSet[Int]() ++= Array(1, 2, 3)
val _ts1: TreeSet[Int] = read(write(ts1))
check(ts1, _ts1)
-
+
// concurrent.TrieMap
val ct1 = TrieMap[Int, String]() ++= Array(1 -> "one", 2 -> "two", 3 -> "three")
val _ct1: TrieMap[Int, String] = read(write(ct1))
@@ -419,70 +420,6 @@ object Test3_mutable {
}
}
-
-//############################################################################
-// Test classes in package "scala.xml"
-
-object Test4_xml {
- import scala.xml.{Attribute, Document, Elem, Null, PrefixedAttribute, Text}
-
- case class Person(name: String, age: Int)
-
- try {
- // Attribute
- val a1 = new PrefixedAttribute("xml", "src", Text("hello"), Null)
- val _a1: Attribute = read(write(a1))
- check(a1, _a1)
-
- // Document
- val d1 = new Document
- d1.docElem = <title></title>
- d1.encoding = Some("UTF-8")
- val _d1: Document = read(write(d1))
- check(d1, _d1)
-
- // Elem
- val e1 = <html><title>title</title><body></body></html>;
- val _e1: Elem = read(write(e1))
- check(e1, _e1)
-
- class AddressBook(a: Person*) {
- private val people: List[Person] = a.toList
- def toXHTML =
- <table cellpadding="2" cellspacing="0">
- <tr>
- <th>Last Name</th>
- <th>First Name</th>
- </tr>
- { for (p <- people) yield
- <tr>
- <td> { p.name } </td>
- <td> { p.age.toString() } </td>
- </tr> }
- </table>;
- }
-
- val people = new AddressBook(
- Person("Tom", 20),
- Person("Bob", 22),
- Person("James", 19))
-
- val e2 =
- <html>
- <body>
- { people.toXHTML }
- </body>
- </html>;
- val _e2: Elem = read(write(e2))
- check(e2, _e2)
- }
- catch {
- case e: Exception =>
- println("Error in Test4_xml: " + e)
- throw e
- }
-}
-
//############################################################################
// Test user-defined classes WITHOUT nesting
@@ -568,7 +505,7 @@ class WithTransient extends Serializable {
@transient private lazy val a2 = 2
@transient object B extends Serializable
@transient private object C extends Serializable
-
+
def test = {
println(a1)
println(a2)
@@ -593,17 +530,18 @@ object Test8 {
//############################################################################
// Test code
+@deprecated("Suppress warnings", since="2.11")
object Test {
def main(args: Array[String]) {
Test1_scala
Test2_immutable
Test3_mutable
- Test4_xml
Test5
Test6
Test7
Test8
Test9_parallel
+ Test10_util
}
}
@@ -614,58 +552,72 @@ object Test {
// Test classes in package "scala.collection.parallel" and subpackages
object Test9_parallel {
import scala.collection.parallel._
-
+
try {
println()
-
+
// UnrolledBuffer
val ub = new collection.mutable.UnrolledBuffer[String]
ub ++= List("one", "two")
val _ub: collection.mutable.UnrolledBuffer[String] = read(write(ub))
check(ub, _ub)
-
+
// mutable.ParArray
val pa = mutable.ParArray("abc", "def", "etc")
val _pa: mutable.ParArray[String] = read(write(pa))
check(pa, _pa)
-
+
// mutable.ParHashMap
val mpm = mutable.ParHashMap(1 -> 2, 2 -> 4)
val _mpm: mutable.ParHashMap[Int, Int] = read(write(mpm))
check(mpm, _mpm)
-
+
// mutable.ParTrieMap
val mpc = mutable.ParTrieMap(1 -> 2, 2 -> 4)
val _mpc: mutable.ParTrieMap[Int, Int] = read(write(mpc))
check(mpc, _mpc)
-
+
// mutable.ParHashSet
val mps = mutable.ParHashSet(1, 2, 3)
val _mps: mutable.ParHashSet[Int] = read(write(mps))
check(mps, _mps)
-
+
// immutable.ParRange
val pr1 = immutable.ParRange(0, 4, 1, true)
val _pr1: immutable.ParRange = read(write(pr1))
check(pr1, _pr1)
-
+
val pr2 = immutable.ParRange(0, 4, 1, false)
val _pr2: immutable.ParRange = read(write(pr2))
check(pr2, _pr2)
-
+
// immutable.ParHashMap
val ipm = immutable.ParHashMap(5 -> 1, 10 -> 2)
val _ipm: immutable.ParHashMap[Int, Int] = read(write(ipm))
check(ipm, _ipm)
-
+
// immutable.ParHashSet
val ips = immutable.ParHashSet("one", "two")
val _ips: immutable.ParHashSet[String] = read(write(ips))
check(ips, _ips)
-
+
} catch {
case e: Exception =>
println("Error in Test5_parallel: " + e)
throw e
}
}
+
+//############################################################################
+// Test classes in package scala.util
+
+object Test10_util {
+ import scala.util.Random
+ def rep[A](n: Int)(f: => A) { if (n > 0) { f; rep(n-1)(f) } }
+
+ {
+ val random = new Random(345)
+ val random2: Random = read(write(random))
+ rep(5) { assert(random.nextInt == random2.nextInt) }
+ }
+}
diff --git a/test/files/jvm/si5471.scala b/test/files/jvm/si5471.scala
index 2c8c4205c5..2efd869b61 100644
--- a/test/files/jvm/si5471.scala
+++ b/test/files/jvm/si5471.scala
@@ -4,12 +4,12 @@ object Test {
def main(args: Array[String]) {
import scala.math.Numeric
import scala.math.Numeric.Implicits._
-
+
val b = BigInt(Long.MaxValue) + 1
def dbl[N :Numeric](n: N) = n.toDouble
def flt[N :Numeric](n: N) = n.toFloat
-
+
println(dbl(b) == b.toDouble)
println(flt(b) == b.toFloat)
}
diff --git a/test/files/jvm/stringbuilder.scala b/test/files/jvm/stringbuilder.scala
index 54951d657b..1fbf61aeab 100644
--- a/test/files/jvm/stringbuilder.scala
+++ b/test/files/jvm/stringbuilder.scala
@@ -2,6 +2,7 @@
*
* @author Stephane Micheloud
*/
+import scala.language.{ postfixOps }
object Test {
def main(args: Array[String]) {
Test1.run() //ctor, reverse
diff --git a/test/files/jvm/t0632.check b/test/files/jvm/t0632.check
deleted file mode 100755
index 681bc9da92..0000000000
--- a/test/files/jvm/t0632.check
+++ /dev/null
@@ -1,12 +0,0 @@
-<foo x="&amp;"/>
-<foo x="&amp;"/>
-<foo x="&amp;"/>
-<foo x="&amp;"/>
-<foo x="&amp;amp;"/>
-<foo x="&amp;amp;"/>
-<foo x="&amp;amp;"/>
-<foo x="&amp;amp;"/>
-<foo x="&amp;&amp;"/>
-<foo x="&amp;&amp;"/>
-<foo x="&amp;&amp;"/>
-<foo x="&amp;&amp;"/>
diff --git a/test/files/jvm/t0632.scala b/test/files/jvm/t0632.scala
deleted file mode 100644
index a2bb5aa7f4..0000000000
--- a/test/files/jvm/t0632.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-object Test {
-import scala.io.Source.fromString
-import scala.xml.parsing.ConstructingParser.fromSource
-import scala.xml.TopScope
- def parse(s:String) = fromSource(fromString(s), false).element(TopScope)
- def main(argv : Array[String]) : Unit = {
-
- println(parse("<foo x='&amp;'/>"))
- println(xml.XML.loadString("<foo x='&amp;'/>"))
- println(<foo x="&amp;"/>)
- println(<foo x={ "&" }/>)
-
- println(xml.XML.loadString("<foo x='&amp;amp;'/>"))
- println(parse("<foo x='&amp;amp;'/>"))
- println(<foo x="&amp;amp;"/>)
- println(<foo x={ "&amp;" }/>)
- println(xml.XML.loadString("<foo x='&amp;&amp;'/>"))
- println(parse("<foo x='&amp;&amp;'/>"))
- println(<foo x="&amp;&amp;"/>)
- println(<foo x={ "&&" }/>)
- }
-}
diff --git a/test/files/jvm/t1116.check b/test/files/jvm/t1116.check
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/files/jvm/t1116.check
+++ /dev/null
diff --git a/test/files/jvm/t1118.check b/test/files/jvm/t1118.check
deleted file mode 100755
index d676b413c9..0000000000
--- a/test/files/jvm/t1118.check
+++ /dev/null
@@ -1,11 +0,0 @@
-
-<hi/> <!-- literal short -->
-<there></there> <!-- literal long -->
-<guys who="you all"></guys> <!-- literal long with attribute-->
-<hows it="going"/> <!-- literal short with attribute -->
-<this>is pretty cool</this> <!-- literal not empty -->
-
-<emptiness></emptiness> <!--programmatic long-->
-<vide/> <!--programmatic short-->
-<elem attr="value"/> <!--programmatic short with attribute-->
-<elem2 attr2="value2"></elem2> <!--programmatic long with attribute-->
diff --git a/test/files/jvm/t1118.scala b/test/files/jvm/t1118.scala
deleted file mode 100755
index 3c86547241..0000000000
--- a/test/files/jvm/t1118.scala
+++ /dev/null
@@ -1,21 +0,0 @@
-import scala.xml._
-
-object Test {
- def main(args: Array[String]) {
- println(<xml:group>
-<hi/> <!-- literal short -->
-<there></there> <!-- literal long -->
-<guys who="you all"></guys> <!-- literal long with attribute-->
-<hows it="going"/> <!-- literal short with attribute -->
-<this>is pretty cool</this> <!-- literal not empty -->
-</xml:group>)
-
- println(Elem(null, "emptiness", Null, TopScope, false) ++ Text(" ") ++ Comment("programmatic long"))
-
- println(Elem(null, "vide", Null, TopScope, true) ++ Text(" ") ++ Comment("programmatic short"))
-
- println(Elem(null, "elem", Attribute("attr", Text("value"), Null), TopScope, true) ++ Text(" ") ++ Comment ("programmatic short with attribute"))
-
- println(Elem(null, "elem2", Attribute("attr2", Text("value2"), Null), TopScope, false) ++ Text(" ") ++ Comment ("programmatic long with attribute"))
- }
-} \ No newline at end of file
diff --git a/test/files/jvm/t1143-2/t1143-2.scala b/test/files/jvm/t1143-2/t1143-2.scala
index 44b1febd8b..13ab13b48c 100644
--- a/test/files/jvm/t1143-2/t1143-2.scala
+++ b/test/files/jvm/t1143-2/t1143-2.scala
@@ -16,43 +16,39 @@ object Serialize {
}
}
-@serializable
@SerialVersionUID(1L)
-class VarModel[T]( getter: => T, setter: T => Unit )
-{
+class VarModel[T](getter: => T, setter: T => Unit) extends Serializable {
Serialize.write(getter)
Serialize.write(setter)
- def this( getter: => T ) = this( getter, null )
+ def this(getter: => T) = this(getter, null)
def getObject: AnyRef = getter.asInstanceOf[AnyRef]
- def setObject( v: AnyRef ) = {
- if( setter==null )
- throw new RuntimeException( "Tried to set readonly model!")
- setter( v.asInstanceOf[T] )
+ def setObject(v: AnyRef) = {
+ if(setter==null)
+ throw new RuntimeException("Tried to set readonly model!")
+ setter(v.asInstanceOf[T])
}
def detach = ()
}
-@serializable
@SerialVersionUID(1L)
-class Printer( p: VarModel[String] ) {
- def print = println( p.getObject );
+class Printer(p: VarModel[String]) extends Serializable {
+ def print = println(p.getObject)
}
class Component extends Marker { }
class Form extends Component { }
-@serializable
@SerialVersionUID(1L)
-class Main {
+class Main extends Serializable {
var pass = "pass"
- def main(args : Array[String]) : Unit = {
+ def main(args: Array[String]): Unit = {
val f = new Form {
- val p = new Printer( new VarModel( pass, s => pass = s ) );
+ val p = new Printer(new VarModel(pass, s => pass = s))
p.print
}
()
diff --git a/test/files/jvm/t1143.check b/test/files/jvm/t1143.check
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/files/jvm/t1143.check
+++ /dev/null
diff --git a/test/files/jvm/t1143.scala b/test/files/jvm/t1143.scala
index 7dd374f432..eb03c7224e 100644
--- a/test/files/jvm/t1143.scala
+++ b/test/files/jvm/t1143.scala
@@ -16,9 +16,8 @@ object Serialize {
}
}
-@serializable
@SerialVersionUID(1L)
-class VarModel[T](getter: => T, setter: T => Unit) {
+class VarModel[T](getter: => T, setter: T => Unit) extends Serializable {
Serialize.write(getter)
Serialize.write(setter)
@@ -35,23 +34,20 @@ class VarModel[T](getter: => T, setter: T => Unit) {
def detach = ()
}
-@serializable
@SerialVersionUID(1L)
-class Printer(p: VarModel[String]) {
+class Printer(p: VarModel[String]) extends Serializable {
def print = println(p.getObject)
}
-@serializable
@SerialVersionUID(1L)
-class Component {
+class Component extends Serializable {
}
class Form extends Component {
}
-@serializable
@SerialVersionUID(1L)
-class Main {
+class Main extends Serializable {
var pass = "pass"
def main(args: Array[String]) {
val f = new Form {
diff --git a/test/files/jvm/t1342/SI.scala b/test/files/jvm/t1342/SI.scala
index 8e3b753210..7c37d4bcd7 100644
--- a/test/files/jvm/t1342/SI.scala
+++ b/test/files/jvm/t1342/SI.scala
@@ -4,7 +4,7 @@ class SI extends JI {
}
}
-object Test extends Application {
+object Test extends App {
val x: JI = new SI
x.varArgsMethod("one", "two")
}
diff --git a/test/files/jvm/t1449.scala b/test/files/jvm/t1449.scala
index 3822cf7dd5..7917d6f6d5 100644
--- a/test/files/jvm/t1449.scala
+++ b/test/files/jvm/t1449.scala
@@ -1,7 +1,10 @@
-import scala.actors.Actor._
-import scala.actors.Future
-import scala.actors.Futures._
+
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.Actor._
+ import scala.actors.Future
+ import scala.actors.Futures._
def main(args: Array[String]) {
val a = actor {
try {
diff --git a/test/files/jvm/t1461.scala b/test/files/jvm/t1461.scala
index a963ec6a12..f0e3cea6cd 100644
--- a/test/files/jvm/t1461.scala
+++ b/test/files/jvm/t1461.scala
@@ -3,7 +3,7 @@ object Test {
def main(args: Array[String]) {
val jl = classOf[Foo].getMethod("jl", classOf[Baz[_]])
jl.getGenericParameterTypes // works fine
-
+
val l = classOf[Foo].getMethod("l", classOf[Baz[_]])
// By debugger inspection l.signature is (Ltest/Baz<J>;)V
l.getGenericParameterTypes // throws GenericSignatureFormatError
diff --git a/test/files/jvm/t1464/MyTrait.scala b/test/files/jvm/t1464/MyTrait.scala
index 014ddf86c3..0b8ccc412b 100644
--- a/test/files/jvm/t1464/MyTrait.scala
+++ b/test/files/jvm/t1464/MyTrait.scala
@@ -1,5 +1,5 @@
trait MyTrait {
type K
def findChildByClass[T <: K with MyTrait]: Unit
-
+
}
diff --git a/test/files/jvm/t1600.scala b/test/files/jvm/t1600.scala
index 7e23687425..5a1b2900c5 100644
--- a/test/files/jvm/t1600.scala
+++ b/test/files/jvm/t1600.scala
@@ -4,23 +4,23 @@
* changes on deserialization.
*/
object Test {
-
+
import collection._
def main(args: Array[String]) {
for (i <- Seq(0, 1, 2, 10, 100)) {
def entries = (0 until i).map(i => (new Foo, i)).toList
def elements = entries.map(_._1)
-
+
val maps = Seq[Map[Foo, Int]](new mutable.HashMap, new mutable.LinkedHashMap,
immutable.HashMap.empty).map(_ ++ entries)
test[Map[Foo, Int]](maps, entries.size, assertMap _)
-
+
val sets = Seq[Set[Foo]](new mutable.HashSet, new mutable.LinkedHashSet,
immutable.HashSet.empty).map(_ ++ elements)
test[Set[Foo]](sets, entries.size, assertSet _)
}
}
-
+
private def test[A <: AnyRef](collections: Seq[A], expectedSize: Int, assertFunction: (A, Int) => Unit) {
for (collection <- collections) {
assertFunction(collection, expectedSize)
@@ -28,19 +28,19 @@ object Test {
val bytes = toBytes(collection)
Foo.hashCodeModifier = 1
val deserializedCollection = toObject[A](bytes)
-
+
assertFunction(deserializedCollection, expectedSize)
assert(deserializedCollection.getClass == collection.getClass,
"collection class should remain the same after deserialization ("+deserializedCollection.getClass+" != "+collection.getClass+")")
Foo.hashCodeModifier = 0
}
}
-
+
private def toObject[A](bytes: Array[Byte]): A = {
val in = new java.io.ObjectInputStream(new java.io.ByteArrayInputStream(bytes))
in.readObject.asInstanceOf[A]
}
-
+
private def toBytes(o: AnyRef): Array[Byte] = {
val bos = new java.io.ByteArrayOutputStream
val out = new java.io.ObjectOutputStream(bos)
@@ -48,7 +48,7 @@ object Test {
out.close
bos.toByteArray
}
-
+
private def assertMap[A, B](map: Map[A, B], expectedSize: Int) {
assert(expectedSize == map.size, "expected map size: " + expectedSize + ", actual size: " + map.size)
map.foreach { case (k, v) =>
@@ -56,21 +56,20 @@ object Test {
assert(map(k) == v)
}
}
-
+
private def assertSet[A](set: Set[A], expectedSize: Int) {
assert(expectedSize == set.size, "expected set size: " + expectedSize + ", actual size: " + set.size)
set.foreach { e => assert(set.contains(e), "contains should return true for element in the set, element: " + e) }
}
-
+
object Foo {
- /* Used to simulate a hashCode change caused by deserializing an instance with an
+ /* Used to simulate a hashCode change caused by deserializing an instance with an
* identity-based hashCode in another JVM.
*/
var hashCodeModifier = 0
}
-
- @serializable
- class Foo {
+
+ class Foo extends Serializable {
override def hashCode = System.identityHashCode(this) + Foo.hashCodeModifier
}
}
diff --git a/test/files/jvm/t1948.check b/test/files/jvm/t1948.check
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/files/jvm/t1948.check
+++ /dev/null
diff --git a/test/files/jvm/t1948.scala b/test/files/jvm/t1948.scala
index 084c956398..95777b8037 100644
--- a/test/files/jvm/t1948.scala
+++ b/test/files/jvm/t1948.scala
@@ -1,7 +1,9 @@
-import scala.actors._
-import scala.actors.Actor._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors._
+ import scala.actors.Actor._
def main (args: Array[String]) {
val actors = (1 to 1000).toList map { x => actor {
diff --git a/test/files/jvm/t2104.check b/test/files/jvm/t2104.check
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/files/jvm/t2104.check
+++ /dev/null
diff --git a/test/files/jvm/ticket2163/ticket2163.java b/test/files/jvm/t2163/t2163.java
index b6511d241c..83bd37d212 100644
--- a/test/files/jvm/ticket2163/ticket2163.java
+++ b/test/files/jvm/t2163/t2163.java
@@ -1,9 +1,9 @@
import java.util.*;
-public class ticket2163 {
+public class t2163 {
public void test() {
List<Integer> array = new ArrayList<Integer>();
- Ticket2163Scala<List> foo = new Ticket2163Scala<List>(array);
+ T2163Scala<List> foo = new T2163Scala<List>(array);
foo.bar(array);
}
}
diff --git a/test/files/jvm/t2163/t2163.scala b/test/files/jvm/t2163/t2163.scala
new file mode 100644
index 0000000000..fdf19c4e25
--- /dev/null
+++ b/test/files/jvm/t2163/t2163.scala
@@ -0,0 +1,10 @@
+
+import scala.language.{ higherKinds }
+
+class T2163Scala[CC[X]](x: CC[Int]) {
+ def bar[DD[X]](meh: DD[Int]): CC[Int] = x
+}
+
+object Test extends App {
+ new t2163().test()
+}
diff --git a/test/files/jvm/t2359.scala b/test/files/jvm/t2359.scala
index 69c69d7b3b..76b78d44f7 100644
--- a/test/files/jvm/t2359.scala
+++ b/test/files/jvm/t2359.scala
@@ -1,6 +1,8 @@
-import scala.actors.Futures._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.Futures._
def main(args: Array[String]) {
val x = future {
try {
diff --git a/test/files/jvm/t2470.cmds b/test/files/jvm/t2470.cmds
deleted file mode 100644
index b4ef0f4aeb..0000000000
--- a/test/files/jvm/t2470.cmds
+++ /dev/null
@@ -1,3 +0,0 @@
-javac Action.java Task.java
-scalac Test_1.scala
-scalac Read_Classfile_2.scala
diff --git a/test/files/jvm/t2530.scala b/test/files/jvm/t2530.scala
index c2925a92d1..b41661e623 100644
--- a/test/files/jvm/t2530.scala
+++ b/test/files/jvm/t2530.scala
@@ -1,6 +1,8 @@
-import scala.actors.{Future, Futures}
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.{Future, Futures}
def main(args:Array[String]) : Unit = {
//scala.actors.Debug.level = 3
@@ -29,7 +31,6 @@ object Test {
}
println("Test done with no deadlock. Try again, it will not occur...")
}
-}
case class Matrix(numRows: Int, numCols: Int, values: Array[Double]) {
@@ -94,3 +95,4 @@ case class Matrix(numRows: Int, numCols: Int, values: Array[Double]) {
}
}
+}
diff --git a/test/files/jvm/t2570.check b/test/files/jvm/t2570.check
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/files/jvm/t2570.check
+++ /dev/null
diff --git a/test/files/jvm/t2570/Test.scala b/test/files/jvm/t2570/Test.scala
index 7944aedae6..ad4d29dd7f 100644
--- a/test/files/jvm/t2570/Test.scala
+++ b/test/files/jvm/t2570/Test.scala
@@ -1,3 +1,3 @@
class Test2 extends Test1[Test3[Test4]]
class Test4
-object Test extends Application {} \ No newline at end of file
+object Test extends App {} \ No newline at end of file
diff --git a/test/files/jvm/t2585.check b/test/files/jvm/t2585.check
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/files/jvm/t2585.check
+++ /dev/null
diff --git a/test/files/jvm/t3003.cmds b/test/files/jvm/t3003.cmds
deleted file mode 100644
index c00396627c..0000000000
--- a/test/files/jvm/t3003.cmds
+++ /dev/null
@@ -1,2 +0,0 @@
-javac Annot.java
-scalac Test_1.scala
diff --git a/test/files/jvm/t3003/Test_1.scala b/test/files/jvm/t3003/Test_1.scala
index 38af66a25a..8ec08bebc6 100644
--- a/test/files/jvm/t3003/Test_1.scala
+++ b/test/files/jvm/t3003/Test_1.scala
@@ -9,7 +9,7 @@ object Test {
. map(f => f.getAnnotations.toList)
. filterNot (_.isEmpty) // there are extra fields under -Xcheckinit
)
-
+
println(xs)
}
}
diff --git a/test/files/jvm/t3102.scala b/test/files/jvm/t3102.scala
index fbcf2e60e6..d0e0704859 100644
--- a/test/files/jvm/t3102.scala
+++ b/test/files/jvm/t3102.scala
@@ -1,7 +1,10 @@
-import scala.actors.{Actor, TIMEOUT}
-import Actor._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.{Actor, TIMEOUT}
+ import Actor._
+
def main(args: Array[String]) {
val a = actor {
try {
diff --git a/test/files/jvm/t3356.scala b/test/files/jvm/t3356.scala
index a9e83fe503..53bfd737cd 100644
--- a/test/files/jvm/t3356.scala
+++ b/test/files/jvm/t3356.scala
@@ -1,3 +1,7 @@
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.{Actor, Exit, !, UncaughtException}
import Actor._
@@ -10,7 +14,6 @@ case class ImageInfo(text: String) {
case class ImageData(text: String)
case class Download(info: ImageInfo)
-object Test {
def scanForImageInfo(url: String): List[ImageInfo] =
List(ImageInfo("A"), ImageInfo("B"))
diff --git a/test/files/jvm/t3365.scala b/test/files/jvm/t3365.scala
index b94e804e63..8321428093 100644
--- a/test/files/jvm/t3365.scala
+++ b/test/files/jvm/t3365.scala
@@ -1,3 +1,7 @@
+
+
+@deprecated("Suppress warnings", since="2.11")
+object Test {
import scala.actors.{ReplyReactor, Channel, Actor, Future}
case class ChannelMsg(chan: Channel[Any])
@@ -27,7 +31,6 @@ class MyActor extends Actor {
}
}
-object Test {
def main(args: Array[String]) {
val a = new MyActor
a.start()
diff --git a/test/files/jvm/t3407.scala b/test/files/jvm/t3407.scala
index 6c2ce85c71..757fa3a438 100644
--- a/test/files/jvm/t3407.scala
+++ b/test/files/jvm/t3407.scala
@@ -1,6 +1,8 @@
-import scala.actors._, scala.actors.Actor._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors._, scala.actors.Actor._
def main(args: Array[String]) {
for (i <- 1 to 10) {
diff --git a/test/files/jvm/t3412-channel.scala b/test/files/jvm/t3412-channel.scala
index fcc439b488..af319d2303 100644
--- a/test/files/jvm/t3412-channel.scala
+++ b/test/files/jvm/t3412-channel.scala
@@ -1,6 +1,8 @@
-import scala.actors._, scala.actors.Actor._, scala.actors.Futures._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors._, scala.actors.Actor._, scala.actors.Futures._
def main(args: Array[String]) {
diff --git a/test/files/jvm/t3412.scala b/test/files/jvm/t3412.scala
index ced15ab5dc..fde6c04cb7 100644
--- a/test/files/jvm/t3412.scala
+++ b/test/files/jvm/t3412.scala
@@ -1,6 +1,8 @@
-import scala.actors._, scala.actors.Actor._, scala.actors.Futures._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors._, scala.actors.Actor._, scala.actors.Futures._
def main(args: Array[String]) {
diff --git a/test/files/jvm/t3415/HelloWorld.scala b/test/files/jvm/t3415/HelloWorld.scala
index 53bf55e444..5ef012390e 100644
--- a/test/files/jvm/t3415/HelloWorld.scala
+++ b/test/files/jvm/t3415/HelloWorld.scala
@@ -1,4 +1,4 @@
-object Test extends Application {
+object Test extends App {
@Hello
def foo() { }
}
diff --git a/test/files/jvm/t3470.scala b/test/files/jvm/t3470.scala
index 5e4242cdd7..bcb1d4f8de 100644
--- a/test/files/jvm/t3470.scala
+++ b/test/files/jvm/t3470.scala
@@ -1,6 +1,8 @@
-import scala.actors._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors._
def expectActorState(a: Reactor[T] forSome { type T }, s: Actor.State.Value) {
var done = false
diff --git a/test/files/jvm/t3838.scala b/test/files/jvm/t3838.scala
index ba8f15fc31..a1a71d1049 100644
--- a/test/files/jvm/t3838.scala
+++ b/test/files/jvm/t3838.scala
@@ -1,6 +1,8 @@
-import scala.actors.Actor._
+
+@deprecated("Suppress warnings", since="2.11")
object Test {
+ import scala.actors.Actor._
def main(args: Array[String]) {
actor {
try {
diff --git a/test/files/jvm/ticket4283/AbstractFoo.java b/test/files/jvm/t4283/AbstractFoo.java
index 74f3827fe3..74f3827fe3 100644
--- a/test/files/jvm/ticket4283/AbstractFoo.java
+++ b/test/files/jvm/t4283/AbstractFoo.java
diff --git a/test/files/jvm/ticket4283/ScalaBipp.scala b/test/files/jvm/t4283/ScalaBipp.scala
index 36dea9f4de..36dea9f4de 100644
--- a/test/files/jvm/ticket4283/ScalaBipp.scala
+++ b/test/files/jvm/t4283/ScalaBipp.scala
diff --git a/test/files/jvm/ticket4283/Test.scala b/test/files/jvm/t4283/Test.scala
index 9bbfaab928..9bbfaab928 100644
--- a/test/files/jvm/ticket4283/Test.scala
+++ b/test/files/jvm/t4283/Test.scala
diff --git a/test/files/jvm/t560bis.check b/test/files/jvm/t560bis.check
deleted file mode 100644
index 91eb4c19a2..0000000000
--- a/test/files/jvm/t560bis.check
+++ /dev/null
@@ -1,2 +0,0 @@
-cool!
-cool!
diff --git a/test/files/jvm/t560bis.scala b/test/files/jvm/t560bis.scala
deleted file mode 100644
index b04303c8a0..0000000000
--- a/test/files/jvm/t560bis.scala
+++ /dev/null
@@ -1,21 +0,0 @@
-object Test {
-import scala.xml._;
-
- def bar(args: Seq[String]) = args match {
- case Seq(a,b,c,d @ _*) => Console.println("cool!")
- case _ => Console.println("bah")
- }
- def foo(args: List[String]) =
- Elem(null,"bla",Null, TopScope, (args map {x => Text(x)}):_*) match {
- case Elem(_,_,_,_,Text("1"),_*) =>
- Console.println("cool!")
- case _ =>
- Console.println("bah")
- }
-
- def main(args: Array[String]) = {
- val li = List("1","2","3","4")
- bar(li)
- foo(li)
- }
-}
diff --git a/test/files/jvm/t680.check b/test/files/jvm/t680.check
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/files/jvm/t680.check
+++ /dev/null
diff --git a/test/files/jvm/t6941/Analyzed_1.flags b/test/files/jvm/t6941/Analyzed_1.flags
new file mode 100644
index 0000000000..ad51758c39
--- /dev/null
+++ b/test/files/jvm/t6941/Analyzed_1.flags
@@ -0,0 +1 @@
+-nowarn
diff --git a/test/files/jvm/t7006.check b/test/files/jvm/t7006.check
new file mode 100644
index 0000000000..6294b14d62
--- /dev/null
+++ b/test/files/jvm/t7006.check
@@ -0,0 +1,29 @@
+[running phase parser on Foo_1.scala]
+[running phase namer on Foo_1.scala]
+[running phase packageobjects on Foo_1.scala]
+[running phase typer on Foo_1.scala]
+[running phase patmat on Foo_1.scala]
+[running phase superaccessors on Foo_1.scala]
+[running phase extmethods on Foo_1.scala]
+[running phase pickler on Foo_1.scala]
+[running phase refchecks on Foo_1.scala]
+[running phase uncurry on Foo_1.scala]
+[running phase tailcalls on Foo_1.scala]
+[running phase specialize on Foo_1.scala]
+[running phase explicitouter on Foo_1.scala]
+[running phase erasure on Foo_1.scala]
+[running phase posterasure on Foo_1.scala]
+[running phase lazyvals on Foo_1.scala]
+[running phase lambdalift on Foo_1.scala]
+[running phase constructors on Foo_1.scala]
+[running phase flatten on Foo_1.scala]
+[running phase mixin on Foo_1.scala]
+[running phase cleanup on Foo_1.scala]
+[running phase delambdafy on Foo_1.scala]
+[running phase icode on Foo_1.scala]
+[running phase inliner on Foo_1.scala]
+[running phase inlinehandlers on Foo_1.scala]
+[running phase closelim on Foo_1.scala]
+[running phase constopt on Foo_1.scala]
+[running phase dce on Foo_1.scala]
+[running phase jvm on icode]
diff --git a/test/files/jvm/t7006/Foo_1.flags b/test/files/jvm/t7006/Foo_1.flags
new file mode 100644
index 0000000000..37b2116413
--- /dev/null
+++ b/test/files/jvm/t7006/Foo_1.flags
@@ -0,0 +1 @@
+-optimise -Ydebug -Xfatal-warnings
diff --git a/test/files/jvm/t7006/Foo_1.scala b/test/files/jvm/t7006/Foo_1.scala
new file mode 100644
index 0000000000..995619ce6b
--- /dev/null
+++ b/test/files/jvm/t7006/Foo_1.scala
@@ -0,0 +1,10 @@
+class Foo_1 {
+ def foo {
+ try {
+ val x = 3 // this will be optimized away, leaving a useless jump only block
+ } finally {
+ print("hello")
+ }
+ while(true){} // ensure infinite loop doesn't break the algoirthm
+ }
+}
diff --git a/test/files/jvm/t7006/Test.scala b/test/files/jvm/t7006/Test.scala
new file mode 100644
index 0000000000..065a23510e
--- /dev/null
+++ b/test/files/jvm/t7006/Test.scala
@@ -0,0 +1,19 @@
+import scala.tools.partest.BytecodeTest
+import scala.tools.asm
+import asm.tree.InsnList
+import scala.collection.JavaConverters._
+
+object Test extends BytecodeTest {
+ def show: Unit = {
+ val classNode = loadClassNode("Foo_1")
+ val methodNode = getMethod(classNode, "foo")
+ assert(count(methodNode.instructions, asm.Opcodes.NOP) == 0)
+ assert(count(methodNode.instructions, asm.Opcodes.GOTO) == 1)
+ }
+
+ def count(insnList: InsnList, opcode: Int): Int = {
+ def isNop(node: asm.tree.AbstractInsnNode): Boolean =
+ (node.getOpcode == opcode)
+ insnList.iterator.asScala.count(isNop)
+ }
+}
diff --git a/test/files/jvm/t7146.scala b/test/files/jvm/t7146.scala
index 2bd03d6d02..aaa3dc7ca4 100644
--- a/test/files/jvm/t7146.scala
+++ b/test/files/jvm/t7146.scala
@@ -1,3 +1,5 @@
+
+import scala.language.{ reflectiveCalls }
import java.util.concurrent.Executor
import scala.concurrent._
import scala.util.control.NoStackTrace
diff --git a/test/files/jvm/t7181/Foo_1.scala b/test/files/jvm/t7181/Foo_1.scala
new file mode 100644
index 0000000000..f9dfdd4442
--- /dev/null
+++ b/test/files/jvm/t7181/Foo_1.scala
@@ -0,0 +1,26 @@
+class Exception1 extends RuntimeException
+class Exception2 extends RuntimeException
+
+class Foo_1 {
+ def foo(baz: Baz) {
+ try {
+ baz.bar
+ } catch {
+ case _: Exception1 => println("exception 1")
+ case _: Exception2 => println("exception 2")
+ } finally {
+ // this should be the only copy of the magic constant 3
+ // making it easy to detect copies of this finally block
+ println(s"finally ${3}")
+ }
+ println(s"normal flow")
+ }
+}
+
+trait Baz {
+ // does it throw? who knows? This way
+ // I can ensure that no optimization that honors
+ // separate compilation could ever
+ // change the exception handling structure
+ def bar: Unit
+}
diff --git a/test/files/jvm/t7181/Test.scala b/test/files/jvm/t7181/Test.scala
new file mode 100644
index 0000000000..35dba436c1
--- /dev/null
+++ b/test/files/jvm/t7181/Test.scala
@@ -0,0 +1,24 @@
+import scala.tools.partest.BytecodeTest
+import scala.tools.asm
+import asm.tree.InsnList
+import scala.collection.JavaConverters._
+
+object Test extends BytecodeTest {
+ def show: Unit = {
+ val classNode = loadClassNode("Foo_1")
+ val methodNode = getMethod(classNode, "foo")
+ // there should be 2 copies of the finally block, each with the magic constant 3
+ // one for the "normal" exit
+ // one for the uncaught exception exit
+ // prior to this PR there would have been 4 since each exception handler would also get a copy
+ val expected = 2
+ val got = countMagicThrees(methodNode.instructions)
+ assert(got == expected, s"expected $expected but got $got magic threes")
+ }
+
+ def countMagicThrees(insnList: InsnList): Int = {
+ def isMagicThree(node: asm.tree.AbstractInsnNode): Boolean =
+ (node.getOpcode == asm.Opcodes.ICONST_3)
+ insnList.iterator.asScala.count(isMagicThree)
+ }
+}
diff --git a/test/files/jvm/throws-annot.scala b/test/files/jvm/throws-annot.scala
index b679b6c121..90b58b9976 100644
--- a/test/files/jvm/throws-annot.scala
+++ b/test/files/jvm/throws-annot.scala
@@ -43,24 +43,24 @@ object TestThrows {
/** Test the top-level mirror that is has the annotations. */
object TL {
-
+
@throws(classOf[IOException])
def read(): Int = 0
-
+
@throws(classOf[ClassCastException])
@throws(classOf[IOException])
def readWith2(): Int = 0
-
+
@throws(classOf[IOException])
@Deprecated
@throws(classOf[NullPointerException])
def readMixed(): Int = 0
-
+
@Deprecated
@throws(classOf[IOException])
@throws(classOf[NullPointerException])
def readMixed2(): Int = 0
-
+
@Deprecated
def readNoEx(): Int = 0
}
diff --git a/test/files/jvm/ticket2163/ticket2163.scala b/test/files/jvm/ticket2163/ticket2163.scala
deleted file mode 100644
index d30bfe251b..0000000000
--- a/test/files/jvm/ticket2163/ticket2163.scala
+++ /dev/null
@@ -1,5 +0,0 @@
-class Ticket2163Scala[CC[X]](x: CC[Int]) {
- def bar[DD[X]](meh: DD[Int]): CC[Int] = x
-}
-
-object Test extends Application {}
diff --git a/test/files/jvm/try-type-tests.scala b/test/files/jvm/try-type-tests.scala
index 17811f64c5..e5e53ee737 100644
--- a/test/files/jvm/try-type-tests.scala
+++ b/test/files/jvm/try-type-tests.scala
@@ -49,6 +49,7 @@ trait TryStandard {
n match {
case Success(v) => assert(false)
case Failure(e: NoSuchElementException) => assert(true)
+ case _ => assert(false)
}
}
@@ -141,4 +142,4 @@ object Test
extends App
with TryStandard {
System.exit(0)
-} \ No newline at end of file
+}
diff --git a/test/files/jvm/typerep.scala b/test/files/jvm/typerep.scala
index 3befc7ff3f..4f900d98d7 100644
--- a/test/files/jvm/typerep.scala
+++ b/test/files/jvm/typerep.scala
@@ -86,7 +86,7 @@ object testArrays {
object testTuples {
println(getType((3, "abc")))
- println(getType(Triple('a', 'b', "c")))
+ println(getType(('a', 'b', "c")))
println(getType(((3, "abc"), (4, "xyz"))))
println(getType(((Some('b'), 3), (Some('a'), 4))))
//println(getType(((Some('b'), 3), (None, 4))))
@@ -109,7 +109,7 @@ object testFuncs {
def f5(f: Int => Int, x: Int) = f(x)
println(getType(f5 _))
println(getType(f5(f1, 1)))
- println
+ println
}
class Foo {
@@ -280,100 +280,74 @@ object TypeRep {
override def toString = "Nothing"
}
- @serializable
case class ClassRep[A](elemRep: TypeRep[A]) extends TypeRep[Class[A]] {
override def toString = "Class[" + elemRep + "]"
}
- @serializable
case class SomeRep[A](elemRep: TypeRep[A]) extends TypeRep[Some[A]] {
override def toString = "Some[" + elemRep + "]"
}
- @serializable
case class NoneRep[A](elemRep: TypeRep[A]) extends TypeRep[Option[A]] {
override def toString = "None[" + elemRep + "]"
}
-
- @serializable
case class ListRep[A](elemRep: TypeRep[A]) extends TypeRep[List[A]] {
override def toString = "List[" + elemRep + "]"
}
-
- @serializable
case class ArrayRep[A](elemRep: TypeRep[A]) extends TypeRep[Array[A]] {
override def toString = "Array[" + elemRep + "]"
}
-
- @serializable
case class Tuple2Rep[A1, A2](_1: TypeRep[A1], _2: TypeRep[A2]) extends TypeRep[(A1, A2)] {
override def toString = "Tuple2[" + _1 + ", " + _2 + "]"
}
- @serializable
case class Tuple3Rep[A1, A2, A3](_1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3]) extends TypeRep[Tuple3[A1, A2, A3]] {
override def toString = "Tuple3[" + _1 + ", " + _2 + ", " + _3 + "]"
}
- @serializable
case class Tuple4Rep[A1, A2, A3, A4](_1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3], _4: TypeRep[A4]) extends TypeRep[Tuple4[A1, A2, A3, A4]] {
override def toString = "Tuple4[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + "]"
}
- @serializable
case class Tuple5Rep[A1, A2, A3, A4, A5](_1: TypeRep[A1], _2: TypeRep[A2], _3: TypeRep[A3], _4: TypeRep[A4], _5: TypeRep[A5]) extends TypeRep[Tuple5[A1, A2, A3, A4, A5]] {
override def toString = "Tuple5[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + "]"
}
- @serializable
case class Tuple6Rep[A1, A2, A3, A4, A5, A6](val _1: TypeRep[A1], val _2: TypeRep[A2], val _3: TypeRep[A3], val _4: TypeRep[A4], val _5: TypeRep[A5], val _6: TypeRep[A6]) extends TypeRep[Tuple6[A1, A2, A3, A4, A5, A6]] {
override def toString = "Tuple6[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + ", " + _6 + "]"
}
- @serializable
case class Tuple7Rep[A1, A2, A3, A4, A5, A6, A7](val _1: TypeRep[A1], val _2: TypeRep[A2], val _3: TypeRep[A3], val _4: TypeRep[A4], val _5: TypeRep[A5], val _6: TypeRep[A6], val _7: TypeRep[A7]) extends TypeRep[Tuple7[A1, A2, A3, A4, A5, A6, A7]] {
override def toString = "Tuple7[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + ", " + _6 + ", " + _7 + "]"
}
- @serializable
case class Tuple8Rep[A1, A2, A3, A4, A5, A6, A7, A8](val _1: TypeRep[A1], val _2: TypeRep[A2], val _3: TypeRep[A3], val _4: TypeRep[A4], val _5: TypeRep[A5], val _6: TypeRep[A6], val _7: TypeRep[A7], val _8: TypeRep[A8]) extends TypeRep[Tuple8[A1, A2, A3, A4, A5, A6, A7, A8]] {
override def toString = "Tuple8[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + ", " + _6 + ", " + _7 + ", " + _8 + "]"
}
- @serializable
case class Tuple9Rep[A1, A2, A3, A4, A5, A6, A7, A8, A9](val _1: TypeRep[A1], val _2: TypeRep[A2], val _3: TypeRep[A3], val _4: TypeRep[A4], val _5: TypeRep[A5], val _6: TypeRep[A6], val _7: TypeRep[A7], val _8: TypeRep[A8], val _9: TypeRep[A9]) extends TypeRep[Tuple9[A1, A2, A3, A4, A5, A6, A7, A8, A9]] {
override def toString = "Tuple9[" + _1 + ", " + _2 + ", " + _3 + ", " + _4 + ", " + _5 + ", " + _6 + ", " + _7 + ", " + _8 + ", " + _9 + "]"
}
- @serializable
case class Function1Rep[A1, B](a1: TypeRep[A1], b: TypeRep[B]) extends TypeRep[Function1[A1, B]] {
override def toString = "Function1[" + a1 + ", " + b + "]"
}
- @serializable
case class Function2Rep[A1, A2, B](a1: TypeRep[A1], a2: TypeRep[A2], b: TypeRep[B]) extends TypeRep[Function2[A1, A2, B]] {
override def toString = "Function2[" + a1 + ", " + a2 + ", " + b + "]"
}
- @serializable
case class Function3Rep[A1, A2, A3, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], b: TypeRep[B]) extends TypeRep[Function3[A1, A2, A3, B]] {
override def toString = "Function3[" + a1 + ", " + a2 + ", " + a3 + ", " + b + "]"
}
- @serializable
case class Function4Rep[A1, A2, A3, A4, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], b: TypeRep[B]) extends TypeRep[Function4[A1, A2, A3, A4, B]] {
override def toString = "Function4[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + b + "]"
}
- @serializable
case class Function5Rep[A1, A2, A3, A4, A5, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], b: TypeRep[B]) extends TypeRep[Function5[A1, A2, A3, A4, A5, B]] {
override def toString = "Function5[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + b + "]"
}
- @serializable
case class Function6Rep[A1, A2, A3, A4, A5, A6, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], b: TypeRep[B]) extends TypeRep[Function6[A1, A2, A3, A4, A5, A6, B]] {
override def toString = "Function6[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + a6 + ", " + b + "]"
}
- @serializable
case class Function7Rep[A1, A2, A3, A4, A5, A6, A7, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], a7: TypeRep[A7], b: TypeRep[B]) extends TypeRep[Function7[A1, A2, A3, A4, A5, A6, A7, B]] {
override def toString = "Function7[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + a6 + ", " + a7 + ", " + b + "]"
}
- @serializable
case class Function8Rep[A1, A2, A3, A4, A5, A6, A7, A8, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], a7: TypeRep[A7], a8: TypeRep[A8], b: TypeRep[B]) extends TypeRep[Function8[A1, A2, A3, A4, A5, A6, A7, A8, B]] {
override def toString = "Function8[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + a6 + ", " + a7 + ", " + a8 + b + "]"
}
- @serializable
case class Function9Rep[A1, A2, A3, A4, A5, A6, A7, A8, A9, B](a1: TypeRep[A1], a2: TypeRep[A2], a3: TypeRep[A3], a4: TypeRep[A4], a5: TypeRep[A5], a6: TypeRep[A6], a7: TypeRep[A7], a8: TypeRep[A8], a9: TypeRep[A9], b: TypeRep[B]) extends TypeRep[Function9[A1, A2, A3, A4, A5, A6, A7, A8, A9, B]] {
override def toString = "Function9[" + a1 + ", " + a2 + ", " + a3 + ", " + a4 + ", " + a5 + ", " + a6 + ", " + a7 + ", " + a8 + ", " + b + "]"
}
/*
- @serializable
case class ObjectRep[A](c: Class) extends TypeRep[A] {
override def toString = c.getName
}
diff --git a/test/files/jvm/unittest_io_Jvm.check b/test/files/jvm/unittest_io_Jvm.check
index d6e855f939..bcfce8cbdb 100644
--- a/test/files/jvm/unittest_io_Jvm.check
+++ b/test/files/jvm/unittest_io_Jvm.check
@@ -1,5 +1,5 @@
lines.size = 5
-
+
This is a file
it is split on several lines.
diff --git a/test/files/jvm/unittest_io_Jvm.scala b/test/files/jvm/unittest_io_Jvm.scala
index 1484774fb3..7c8ef131bc 100644
--- a/test/files/jvm/unittest_io_Jvm.scala
+++ b/test/files/jvm/unittest_io_Jvm.scala
@@ -3,7 +3,7 @@ import scala.io.Source
object Test {
def main(args: Array[String]) {
val lines = Source.fromString(
- """|
+ """|
|This is a file
|it is split on several lines.
|
diff --git a/test/files/jvm/unittest_xml.scala b/test/files/jvm/unittest_xml.scala
deleted file mode 100644
index 106334e625..0000000000
--- a/test/files/jvm/unittest_xml.scala
+++ /dev/null
@@ -1,101 +0,0 @@
-import scala.xml.{ MetaData, Null, Utility, PrefixedAttribute, UnprefixedAttribute }
-
-object Test {
-
- def main(args:Array[String]) = {
- MetaDataTest.run()
- UtilityTest.run()
- }
-
- object MetaDataTest {
-
- import scala.xml.{ TopScope, NamespaceBinding, Node, Atom, Text }
-
- def domatch(x:Node): Node = {
- x match {
- case Node("foo", md @ UnprefixedAttribute(_, value, _), _*) if !value.isEmpty =>
- md("bar")(0)
- case _ => new Atom(3)
- }
- }
-
- def run() {
-
- var x: MetaData = Null
- var s: NamespaceBinding = TopScope
-
- // testing method def apply(uri:String, scp:NamespaceBinding, k:String): Seq[Node]
- // def apply(k:String): Seq[Node]
-
- assert(null == x("za://foo.com", s, "bar" ), "absent element (prefixed) 1")
- assert(null == x("bar"), "absent element (unprefix) 1")
-
- assert(None == x.get("za://foo.com", s, "bar" ), "absent element (prefixed) 2")
- assert(None == x.get("bar"), "absent element (unprefix) 2")
-
- x = new PrefixedAttribute("zo","bar", new Atom(42), x)
- s = new NamespaceBinding("zo","za://foo.com",s)
-
- assert(new Atom(42) == x("za://foo.com", s, "bar" ), "present element (prefixed) 3")
- assert(null == x("bar"), "present element (unprefix) 3")
-
- assert(Some(new Atom(42)) == x.get("za://foo.com", s, "bar" ), "present element (prefixed) 4")
- assert(None == x.get("bar"), "present element (unprefix) 4")
-
- x = new UnprefixedAttribute("bar","meaning", x)
-
- assert(null == x(null, s, "bar"), "present element (prefixed) 5")
- assert(Text("meaning") == x("bar"), "present element (unprefix) 5")
-
- assert(None == x.get(null, s, "bar" ), "present element (prefixed) 6")
- assert(Some(Text("meaning")) == x.get("bar"), "present element (unprefix) 6")
-
- val z = <foo bar="gar"/>
- val z2 = <foo/>
-
- assert(Text("gar") == domatch(z), "attribute extractor 1")
- assert(new Atom(3) == domatch(z2), "attribute extractor 2")
-
- }
- }
-
- object UtilityTest {
- def run() {
- assert(Utility.isNameStart('b'))
- assert(!Utility.isNameStart(':'))
-
- val x = <foo>
- <toomuchws/>
- </foo>
-
- val y = xml.Utility.trim(x)
-
- assert(1 == (y match { case <foo><toomuchws/></foo> => 1 }), "trim 1")
-
- val x2 = <foo>
- <toomuchws> a b b a </toomuchws>
- </foo>
-
- val y2 = xml.Utility.trim(x2)
-
- assert(2 == (y2 match { case <foo><toomuchws>a b b a</toomuchws></foo> => 2 }), "trim 2")
-
- val z = <bar>''</bar>
- val z1 = z.toString
-
- assert("<bar>''</bar>" == z1, "apos unescaped")
-
- val q = xml.Utility.sort(<a g='3' j='2' oo='2' a='2'/>)
- assert(" a=\"2\" g=\"3\" j=\"2\" oo=\"2\"" == xml.Utility.sort(q.attributes).toString)
-
- val pp = new xml.PrettyPrinter(80,5)
- assert("<a a=\"2\" g=\"3\" j=\"2\" oo=\"2\"/>" == pp.format(q))
-
- <hi>
- <there/>
- <guys/>
- </hi>.hashCode // Bug #777
- }
- }
-
-}
diff --git a/test/files/jvm/unreachable/Foo_1.flags b/test/files/jvm/unreachable/Foo_1.flags
new file mode 100644
index 0000000000..ce6e93b3da
--- /dev/null
+++ b/test/files/jvm/unreachable/Foo_1.flags
@@ -0,0 +1 @@
+-Ynooptimise \ No newline at end of file
diff --git a/test/files/jvm/unreachable/Foo_1.scala b/test/files/jvm/unreachable/Foo_1.scala
new file mode 100644
index 0000000000..600b96bb18
--- /dev/null
+++ b/test/files/jvm/unreachable/Foo_1.scala
@@ -0,0 +1,112 @@
+import scala.sys.error
+
+class Foo_1 {
+ def unreachableNormalExit: Int = {
+ return 42
+ 0
+ }
+
+ def unreachableIf: Int = {
+ return 42
+ if (util.Random.nextInt % 2 == 0)
+ 0
+ else
+ 1
+ }
+
+ def unreachableIfBranches: Int = {
+ if (util.Random.nextInt % 2 == 0)
+ return 42
+ else
+ return 42
+
+ return 0
+ }
+
+ def unreachableOneLegIf: Int = {
+ if (util.Random.nextInt % 2 == 0)
+ return 42
+
+ return 42
+ }
+
+ def unreachableLeftBranch: Int = {
+ val result = if (util.Random.nextInt % 2 == 0)
+ return 42
+ else
+ 42
+
+ return result
+ }
+
+ def unreachableRightBranch: Int = {
+ val result = if (util.Random.nextInt % 2 == 0)
+ 42
+ else
+ return 42
+
+ return result
+ }
+
+ def unreachableTryCatchFinally: Int = {
+ return 42
+ try {
+ return 0
+ } catch {
+ case x: Throwable => return 1
+ } finally {
+ return 2
+ }
+ return 3
+ }
+
+ def unreachableAfterTry: Int = {
+ try {
+ return 42
+ } catch {
+ case x: Throwable => return 2
+ }
+ return 3
+ }
+
+ def unreachableAfterCatch: Int = {
+ try {
+ error("haha")
+ } catch {
+ case x: Throwable => return 42
+ }
+ return 3
+ }
+
+ def unreachableAfterFinally: Int = {
+ try {
+ return 1
+ } catch {
+ case x: Throwable => return 2
+ } finally {
+ return 42
+ }
+ return 3
+ }
+
+ def unreachableSwitch: Int = {
+ return 42
+ val x = util.Random.nextInt % 2
+ x match {
+ case 0 => return 0
+ case 1 => return 1
+ case _ => error("wtf")
+ }
+ 2
+ }
+
+ def unreachableAfterSwitch: Int = {
+ val x = util.Random.nextInt % 2
+ x match {
+ case 0 => return 42
+ case 1 => return 41 + x
+ case _ => error("wtf")
+ }
+ 2
+ }
+}
diff --git a/test/files/jvm/unreachable/Test.scala b/test/files/jvm/unreachable/Test.scala
new file mode 100644
index 0000000000..3f520eb106
--- /dev/null
+++ b/test/files/jvm/unreachable/Test.scala
@@ -0,0 +1,23 @@
+import scala.tools.partest.BytecodeTest
+import scala.tools.asm
+import asm.tree.InsnList
+import scala.collection.JavaConverters._
+
+object Test extends BytecodeTest {
+ def show: Unit = {
+ val classNode = loadClassNode("Foo_1")
+ // Foo_1 is full of unreachable code which if not elimintated
+ // will result in NOPs as can be confirmed by adding -Ydisable-unreachable-prevention
+ // to Foo_1.flags
+ for (methodNode <- classNode.methods.asScala) {
+ val got = count(methodNode.instructions, asm.Opcodes.NOP)
+ if (got != 0) println(s"Found $got NOP(s) in ${methodNode.name}")
+ }
+ }
+
+ def count(insnList: InsnList, opcode: Int): Int = {
+ def isNop(node: asm.tree.AbstractInsnNode): Boolean =
+ (node.getOpcode == opcode)
+ insnList.iterator.asScala.count(isNop)
+ }
+} \ No newline at end of file
diff --git a/test/files/jvm/value-class-boxing.check b/test/files/jvm/value-class-boxing.check
new file mode 100644
index 0000000000..20a9fe2ba8
--- /dev/null
+++ b/test/files/jvm/value-class-boxing.check
@@ -0,0 +1,7 @@
+a2 and a1: bytecode identical
+a3 and a1: bytecode identical
+a4 and a1: bytecode identical
+b2 and b1: bytecode identical
+b3 and b1: bytecode identical
+b4 and b1: bytecode identical
+b5 and b1: bytecode identical
diff --git a/test/files/jvm/value-class-boxing/Analyzed_1.scala b/test/files/jvm/value-class-boxing/Analyzed_1.scala
new file mode 100644
index 0000000000..dec8565351
--- /dev/null
+++ b/test/files/jvm/value-class-boxing/Analyzed_1.scala
@@ -0,0 +1,17 @@
+class Wrap(val x: Int) extends AnyVal {
+ def ***(other: Bip): Wrap = new Wrap(x * other.x)
+}
+class Bip(val x: Int) extends AnyVal
+
+class SameBytecode {
+ def a1(x: Int, y: Int): Int = x + y
+ def a2(x: Wrap, y: Wrap): Wrap = new Wrap(x.x + y.x)
+ def a3(x: Int, y: Wrap): Wrap = new Wrap(x + y.x)
+ def a4(x: Int, y: Wrap): Int = x + y.x
+
+ def b1(x: Wrap, y: Int): Int = (x *** new Bip(y)).x
+ def b2(x: Wrap, y: Bip): Wrap = x *** y
+ def b3(x: Wrap, y: Int): Wrap = x *** new Bip(y)
+ def b4(x: Wrap, y: Bip): Bip = new Bip((x *** y).x)
+ def b5(x: Wrap, y: Int): Bip = new Bip((x *** new Bip(y)).x)
+}
diff --git a/test/files/jvm/value-class-boxing/test.scala b/test/files/jvm/value-class-boxing/test.scala
new file mode 100644
index 0000000000..cf331832de
--- /dev/null
+++ b/test/files/jvm/value-class-boxing/test.scala
@@ -0,0 +1,15 @@
+import scala.tools.partest.BytecodeTest
+
+object Test extends BytecodeTest {
+ def show: Unit = {
+ val classNode = loadClassNode("SameBytecode")
+ List("a2", "a3", "a4") foreach { m =>
+ print(m + " and a1: ")
+ sameBytecode(getMethod(classNode, "a1"), getMethod(classNode, m))
+ }
+ List("b2", "b3", "b4", "b5") foreach { m =>
+ print(m + " and b1: ")
+ sameBytecode(getMethod(classNode, "b1"), getMethod(classNode, m))
+ }
+ }
+}
diff --git a/test/files/jvm/varargs/JavaClass.java b/test/files/jvm/varargs/JavaClass.java
index 536e9a38fb..9851e1b78b 100644
--- a/test/files/jvm/varargs/JavaClass.java
+++ b/test/files/jvm/varargs/JavaClass.java
@@ -4,7 +4,7 @@
public class JavaClass {
public static <T> void varargz(int i, T... v) {
}
-
+
public static void callSomeAnnotations() {
VaClass va = new VaClass();
va.vs(4, "", "", "");
diff --git a/test/files/jvm/varargs/VaClass.scala b/test/files/jvm/varargs/VaClass.scala
index 8e9cbdbb3f..6343f9c6f6 100644
--- a/test/files/jvm/varargs/VaClass.scala
+++ b/test/files/jvm/varargs/VaClass.scala
@@ -5,9 +5,9 @@ import annotation.varargs
class VaClass {
-
+
@varargs def vs(a: Int, b: String*) = println(a + b.length)
@varargs def vi(a: Int, b: Int*) = println(a + b.sum)
@varargs def vt[T](a: Int, b: T*) = println(a + b.length)
-
+
}
diff --git a/test/files/jvm/xml01.check b/test/files/jvm/xml01.check
deleted file mode 100755
index d78e6df410..0000000000
--- a/test/files/jvm/xml01.check
+++ /dev/null
@@ -1,8 +0,0 @@
-equality
-xpath \
-xpath \\ DESCENDANTS
-<book><author>Peter Buneman</author><author>Dan Suciu</author><title>Data on ze web</title></book>
--- group nodes
-<f><a/><b/><c/></f>
-<a/><f><a/><b/><c/></f><a/><b/><c/>
-attribute value normalization
diff --git a/test/files/jvm/xml01.scala b/test/files/jvm/xml01.scala
deleted file mode 100644
index 2fab650637..0000000000
--- a/test/files/jvm/xml01.scala
+++ /dev/null
@@ -1,181 +0,0 @@
-import java.io.StringReader
-import org.xml.sax.InputSource
-
-import scala.util.logging._
-import scala.xml._
-
-object Test extends App {
- val e: scala.xml.MetaData = Null //Node.NoAttributes
- val sc: scala.xml.NamespaceBinding = TopScope
-
- val xmlFile1 = "<hello><world/></hello>";
- val isrc1 = new InputSource(new StringReader(xmlFile1))
- val parsedxml1 = XML.load(isrc1)
- val isrc11 = new InputSource(new StringReader(xmlFile1))
- val parsedxml11 = XML.load(isrc11)
-
- val c = new Node {
- def label = "hello"
- override def hashCode() =
- Utility.hashCode(prefix, label, attributes.hashCode(), scope.hashCode(), child);
- def child = Elem(null, "world", e, sc);
- //def attributes = e;
- override def text = ""
- }
-
- println("equality")
- assert(c == parsedxml11)
- assert(parsedxml1 == parsedxml11)
- assert(List(parsedxml1) sameElements List(parsedxml11))
- assert(Array(parsedxml1).toList sameElements List(parsedxml11))
-
- val x2 = "<book><author>Peter Buneman</author><author>Dan Suciu</author><title>Data on ze web</title></book>";
-
- val i = new InputSource(new StringReader(x2))
- val x2p = XML.load(i)
-
- assert(x2p == Elem(null, "book" , e, sc,
- Elem(null, "author", e, sc,Text("Peter Buneman")),
- Elem(null, "author", e, sc,Text("Dan Suciu")),
- Elem(null, "title" , e, sc,Text("Data on ze web"))))
-
- val xmlFile2 = "<bib><book><author>Peter Buneman</author><author>Dan Suciu</author><title>Data on ze web</title></book><book><author>John Mitchell</author><title>Foundations of Programming Languages</title></book></bib>";
- val isrc2 = new InputSource(new StringReader(xmlFile2))
- val parsedxml2 = XML.load(isrc2)
-
- println("xpath \\")
-
- assert(parsedxml1 \ "_" sameElements List(Elem(null,"world", e, sc)))
-
- assert(parsedxml1 \ "world" sameElements List(Elem(null,"world", e, sc)))
-
- assert(
- (parsedxml2 \ "_") sameElements List(
- Elem(null,"book", e, sc,
- Elem(null,"author", e, sc, Text("Peter Buneman")),
- Elem(null,"author", e, sc, Text("Dan Suciu")),
- Elem(null,"title" , e, sc, Text("Data on ze web"))),
- Elem(null,"book",e,sc,
- Elem(null,"author",e,sc,Text("John Mitchell")),
- Elem(null,"title",e,sc,Text("Foundations of Programming Languages"))))
- )
- assert((parsedxml2 \ "author").isEmpty)
-
- assert(
- (parsedxml2 \ "book") sameElements List(
- Elem(null,"book",e,sc,
- Elem(null,"author", e, sc, Text("Peter Buneman")),
- Elem(null,"author", e, sc, Text("Dan Suciu")),
- Elem(null,"title" , e, sc, Text("Data on ze web"))),
- Elem(null,"book",e,sc,
- Elem(null,"author", e, sc, Text("John Mitchell")),
- Elem(null,"title" , e, sc, Text("Foundations of Programming Languages")))
- )
- )
-
- assert(
- (parsedxml2 \ "_" \ "_") sameElements List(
- Elem(null,"author", e, sc, Text("Peter Buneman")),
- Elem(null,"author", e, sc, Text("Dan Suciu")),
- Elem(null,"title" , e, sc, Text("Data on ze web")),
- Elem(null,"author", e, sc, Text("John Mitchell")),
- Elem(null,"title" , e, sc, Text("Foundations of Programming Languages"))
- )
- )
-
- assert(
- (parsedxml2 \ "_" \ "author") sameElements List(
- Elem(null,"author", e, sc, Text("Peter Buneman")),
- Elem(null,"author", e, sc, Text("Dan Suciu")),
- Elem(null,"author", e, sc, Text("John Mitchell"))
- )
- )
-
- assert((parsedxml2 \ "_" \ "_" \ "author").isEmpty)
-
- Console.println("xpath \\\\ DESCENDANTS");
-
- assert(
- (parsedxml2 \\ "author") sameElements List(
- Elem(null,"author", e, sc, Text("Peter Buneman")),
- Elem(null,"author", e, sc, Text("Dan Suciu")),
- Elem(null,"author", e, sc, Text("John Mitchell"))
- )
- )
-
- assert(
- (parsedxml2 \\ "title") sameElements List(
- Elem(null,"title", e, sc, Text("Data on ze web")),
- Elem(null,"title", e, sc, Text("Foundations of Programming Languages")))
- )
-
-
- println(
- (parsedxml2 \\ "book" ){ n:Node => (n \ "title") xml_== "Data on ze web" }
- )
-
- assert(
- ((new NodeSeq { val theSeq = List( parsedxml2 ) }) \\ "_") sameElements List(
- Elem(null,"bib",e,sc,
- Elem(null,"book",e,sc,
- Elem(null, "author", e, sc, Text("Peter Buneman")),
- Elem(null, "author", e, sc, Text("Dan Suciu")),
- Elem(null, "title" , e, sc, Text("Data on ze web"))),
- Elem(null,"book",e,sc,
- Elem(null,"author",e,sc,Text("John Mitchell")),
- Elem(null,"title",e,sc,Text("Foundations of Programming Languages")))),
- Elem(null,"book",e,sc,
- Elem(null,"author",e,sc,Text("Peter Buneman")),
- Elem(null,"author",e,sc,Text("Dan Suciu")),
- Elem(null,"title",e,sc,Text("Data on ze web"))),
- Elem(null,"author",e,sc,Text("Peter Buneman")),
- Elem(null,"author",e,sc,Text("Dan Suciu")),
- Elem(null,"title",e,sc,Text("Data on ze web")),
- Elem(null,"book",e,sc,
- Elem(null,"author",e,sc,Text("John Mitchell")),
- Elem(null,"title",e,sc,Text("Foundations of Programming Languages"))),
- Elem(null,"author",e,sc,Text("John Mitchell")),
- Elem(null,"title",e,sc,Text("Foundations of Programming Languages"))
- )
- )
-
- // test group node
- Console println "-- group nodes"
- val zx1: Node = Group { <a/><b/><c/> }
- val zy1 = <f>{zx1}</f>
- Console println zy1.toString()
-
- val zx2: Node = Group { List(<a/>,zy1,zx1) }
- Console println zx2.toString()
-
- val zz1 = <xml:group><a/><b/><c/></xml:group>
-
- assert(zx1 xml_== zz1)
- assert(zz1.length == 3)
-
- // unparsed
-
- println("attribute value normalization")
- val xmlAttrValueNorm = "<personne id='p0003' nom='&#x015e;ahingöz' />";
- {
- val isrcA = new InputSource( new StringReader(xmlAttrValueNorm) );
- val parsedxmlA = XML.load(isrcA);
- val c = (parsedxmlA \ "@nom").text.charAt(0);
- assert(c == '\u015e');
- }
- // buraq: if the following test fails with 'character x not allowed', it is
- // related to the mutable variable in a closures in MarkupParser.parsecharref
- {
- val isr = scala.io.Source.fromString(xmlAttrValueNorm);
- val pxmlB = scala.xml.parsing.ConstructingParser.fromSource(isr,false);
- val parsedxmlB = pxmlB.element(TopScope);
- val c = (parsedxmlB \ "@nom").text.charAt(0);
- assert(c == '\u015e');
- }
-
- // #60 test by round trip
-
- val p = scala.xml.parsing.ConstructingParser.fromSource(scala.io.Source.fromString("<foo bar:attr='&amp;'/>"),true)
- val n = p.element(new scala.xml.NamespaceBinding("bar","BAR",scala.xml.TopScope))(0)
- assert( n.attributes.get("BAR", n, "attr").nonEmpty)
-}
diff --git a/test/files/jvm/xml02.check b/test/files/jvm/xml02.check
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/files/jvm/xml02.check
+++ /dev/null
diff --git a/test/files/jvm/xml02.scala b/test/files/jvm/xml02.scala
deleted file mode 100644
index b830a0e694..0000000000
--- a/test/files/jvm/xml02.scala
+++ /dev/null
@@ -1,78 +0,0 @@
-object Test {
-
- def main(args: Array[String]) {
- XmlEx.run()
- XmlEy.run()
- XmlPat.run()
- DodgyNamespace.run()
- }
-
- import scala.xml.{NodeSeq, Utility}
- import NodeSeq.seqToNodeSeq
-
- val ax = <hello foo="bar" x:foo="baz" xmlns:x="the namespace from outer space">
- <world/>
- </hello>
-
- val cx = <z:hello foo="bar" xmlns:z="z" x:foo="baz" xmlns:x="the namespace from outer space">
- crazy text world
- </z:hello>
-
- val bx = <hello foo="bar&amp;x"></hello>
-
- object XmlEx {
-
- def run() {
- assert((ax \ "@foo") xml_== "bar") // uses NodeSeq.view!
- assert((ax \ "@foo") xml_== xml.Text("bar")) // dto.
- assert((bx \ "@foo") xml_== "bar&x") // dto.
- assert((bx \ "@foo") xml_sameElements List(xml.Text("bar&x")))
- assert("<hello foo=\"bar&amp;x\"></hello>" == bx.toString)
- }
- }
-
- object XmlEy {
- def run() {
- val z = ax \ "@{the namespace from outer space}foo"
- assert((ax \ "@{the namespace from outer space}foo") xml_== "baz")
- assert((cx \ "@{the namespace from outer space}foo") xml_== "baz")
-
- try {
- ax \ "@"
- assert(false)
- } catch {
- case _: IllegalArgumentException =>
- }
- try {
- ax \ "@{"
- assert(false)
- } catch {
- case _: IllegalArgumentException =>
- }
- try {
- ax \ "@{}"
- assert(false)
- } catch {
- case _: IllegalArgumentException =>
- }
-
- }
- }
-
- object XmlPat {
- def run() {
- assert(<hello/> match { case <hello/> => true; case _ => false; })
- assert(<x:ga xmlns:x="z"/> match { case <x:ga/> => true; case _ => false; });
- assert(Utility.trim(cx) match { case n @ <hello>crazy text world</hello> if (n \ "@foo") xml_== "bar" => true; })
- assert(Utility.trim(cx) match { case n @ <z:hello>crazy text world</z:hello> if (n \ "@foo") xml_== "bar" => true; })
- }
- }
-
- object DodgyNamespace {
- def run() {
- val x = <flog xmlns:ee="http://ee.com"><foo xmlns:dog="http://dog.com"><dog:cat/></foo></flog>
- assert(x.toString.matches(".*xmlns:dog=\"http://dog.com\".*"));
- }
- }
-
-}
diff --git a/test/files/jvm/xml03syntax.check b/test/files/jvm/xml03syntax.check
deleted file mode 100755
index edcdbdd2ba..0000000000
--- a/test/files/jvm/xml03syntax.check
+++ /dev/null
@@ -1,26 +0,0 @@
-true
-true
-true
-<hello>world</hello>
-true
-<hello>1.5</hello>
-true
-<hello>5</hello>
-true
-<hello>true</hello>
-true
-<hello>5</hello>
-true
-<hello>27</hello>
-true
-<hello>1 2 3 4</hello>
-1
-2
-3
-4
-<hello>2 4</hello>
-2
-4
-
-node=<elem key="<b>hello</b>"/>, key=Some(<b>hello</b>)
-node=<elem/>, key=None
diff --git a/test/files/jvm/xml03syntax.scala b/test/files/jvm/xml03syntax.scala
deleted file mode 100644
index 2c93f7c176..0000000000
--- a/test/files/jvm/xml03syntax.scala
+++ /dev/null
@@ -1,97 +0,0 @@
-import scala.xml._
-
-object Test {
-
- private def handle[A](x: Node): A = {
- println(x)
- x.child(0).asInstanceOf[Atom[A]].data
- }
-
- def main(args: Array[String]) {
- test1()
- test2()
- test3()
- }
-
- private def test1() {
- val xNull = <hello>{null}</hello> // these used to be Atom(unit), changed to empty children
-
- println(xNull.child sameElements Nil)
-
- val x0 = <hello>{}</hello> // these used to be Atom(unit), changed to empty children
- val x00 = <hello>{ }</hello> // dto.
-
- val xa = <hello>{ "world" }</hello>
-
-
- println(x0.child sameElements Nil)
- println(x00.child sameElements Nil)
- println(handle[String](xa) == "world")
-
- val xb = <hello>{ 1.5 }</hello>
-
- println(handle[Double](xb) == 1.5)
-
- val xc = <hello>{ 5 }</hello>
-
- println(handle[Int](xc) == 5)
-
- val xd = <hello>{ true }</hello>
-
- println(handle[Boolean](xd) == true)
-
- val xe = <hello>{ 5:Short }</hello>
-
- println(handle[Short](xe) == (5:Short))
-
- val xf = <hello>{ val x = 27; x }</hello>
-
- println(handle[Int](xf) == 27)
-
- val xg = <hello>{ List(1,2,3,4) }</hello>
-
- println(xg)
- for (z <- xg.child) {
- println(z.toString() + {if (z.isInstanceOf[Text]) "(is text node ' ')" else ""})
- }
-
- val xh = <hello>{ for(x <- List(1,2,3,4) if x % 2 == 0) yield x }</hello>
-
- println(xh)
- for (z <- xh.child) {
- println(z.toString() + {if (z.isInstanceOf[Text]) "(is text node ' ')" else ""})
- }
- println
- }
-
- /** see SVN r13821 (emir): support for <elem key={x:Option[Seq[Node]]} />,
- * so that Options can be used for optional attributes.
- */
- private def test2() {
- val x1: Option[Seq[Node]] = Some(<b>hello</b>)
- val n1 = <elem key={x1} />;
- println("node="+n1+", key="+n1.attribute("key"))
-
- val x2: Option[Seq[Node]] = None
- val n2 = <elem key={x2} />;
- println("node="+n2+", key="+n2.attribute("key"))
- }
-
- private def test3() {
- // this demonstrates how to handle entities
- val s = io.Source.fromString("<a>&nbsp;</a>")
- object parser extends xml.parsing.ConstructingParser(s, false /*ignore ws*/) {
- override def replacementText(entityName: String): io.Source = {
- entityName match {
- case "nbsp" => io.Source.fromString("\u0160");
- case _ => super.replacementText(entityName);
- }
- }
- nextch; // !!important, to initialize the parser
- }
- val parsed = parser.element(TopScope) // parse the source as element
- // alternatively, we could call document()
- parsed
- }
-
-}
diff --git a/test/files/jvm/xml04embed.check b/test/files/jvm/xml04embed.check
deleted file mode 100644
index e71e645149..0000000000
--- a/test/files/jvm/xml04embed.check
+++ /dev/null
@@ -1,3 +0,0 @@
-{
-}
-{}{}{}
diff --git a/test/files/jvm/xml04embed.scala b/test/files/jvm/xml04embed.scala
deleted file mode 100644
index fa453e4295..0000000000
--- a/test/files/jvm/xml04embed.scala
+++ /dev/null
@@ -1,10 +0,0 @@
-object Test {
- def main(args: Array[String]) {
- val ya = <x>{{</x>
- println(ya.text)
- val ua = <x>}}</x>
- println(ua.text)
- val za = <x>{{}}{{}}{{}}</x>
- println(za.text)
- }
-}
diff --git a/test/files/jvm/xml05.check b/test/files/jvm/xml05.check
index 8d3e803bc8..92ea995350 100644
--- a/test/files/jvm/xml05.check
+++ b/test/files/jvm/xml05.check
@@ -1,11 +1,7 @@
Type in expressions to have them evaluated.
Type :help for more information.
-scala>
-
scala> <city name="San Jos&eacute;"/>
res0: scala.xml.Elem = <city name="San Jos&eacute;"/>
scala>
-
-scala>
diff --git a/test/files/jvm/xmlattr.check b/test/files/jvm/xmlattr.check
deleted file mode 100644
index a87420d86c..0000000000
--- a/test/files/jvm/xmlattr.check
+++ /dev/null
@@ -1,18 +0,0 @@
-true
-true
-true
-true
-true
-true
-removal of duplicates for unprefixed attributes in append = 1
-true
-true
-true
-true
-true
-true
-true
-true
-true
-<b x="&amp;"/>
-<b x="&amp;"/>
diff --git a/test/files/jvm/xmlattr.scala b/test/files/jvm/xmlattr.scala
deleted file mode 100644
index d214642eb6..0000000000
--- a/test/files/jvm/xmlattr.scala
+++ /dev/null
@@ -1,63 +0,0 @@
-import xml.{ NodeSeq, Null, Text, UnprefixedAttribute }
-
-object Test {
-
- def main(args: Array[String]) {
- UnprefixedAttributeTest()
- AttributeWithOptionTest()
- AttributeOutputTest()
- }
-
- object UnprefixedAttributeTest {
- def apply() {
- val x = new UnprefixedAttribute("foo","bar", Null)
- println(Some(Text("bar")) == x.get("foo"))
- println(Text("bar") == x("foo"))
- println(None == x.get("no_foo"))
- println(null == x("no_foo"))
-
- val y = x.remove("foo")
- println(Null == y)
-
- val z = new UnprefixedAttribute("foo", null:NodeSeq, x)
- println(None == z.get("foo"))
-
- var appended = x append x append x append x
- var len = 0; while (appended ne Null) {
- appended = appended.next
- len = len + 1
- }
- println("removal of duplicates for unprefixed attributes in append = " + len)
- }
- }
-
- object AttributeWithOptionTest {
- def apply() {
- val x = new UnprefixedAttribute("foo", Some(Text("bar")), Null)
-
- println(Some(Text("bar")) == x.get("foo"))
- println(Text("bar") == x("foo"))
- println(None == x.get("no_foo"))
- println(null == x("no_foo"))
-
- val attr1 = Some(Text("foo value"))
- val attr2 = None
- val y = <b foo={attr1} bar={attr2} />
- println(Some(Text("foo value")) == y.attributes.get("foo"));
- println(Text("foo value") == y.attributes("foo"))
- println(None == y.attributes.get("bar"))
- println(null == y.attributes("bar"))
-
- val z = new UnprefixedAttribute("foo", None, x)
- println(None == z.get("foo"))
- }
- }
-
- object AttributeOutputTest {
- def apply() {
- println(<b x="&amp;"/>)
- println(<b x={"&"}/>)
- }
- }
-
-}
diff --git a/test/files/jvm/xmlmore.check b/test/files/jvm/xmlmore.check
deleted file mode 100644
index 29f144c89f..0000000000
--- a/test/files/jvm/xmlmore.check
+++ /dev/null
@@ -1,10 +0,0 @@
-<!-- thissa comment -->
-<?this is a pi foo bar = && {{ ?>
-
- &quot;Come, come again, whoever you are, come!
-Heathen, fire worshipper or idolatrous, come!
-Come even if you broke your penitence a hundred times,
-Ours is the portal of hope, come as you are.&quot;
- Mevlana Celaleddin Rumi
-<foo><br /></foo>
-End Test
diff --git a/test/files/jvm/xmlmore.scala b/test/files/jvm/xmlmore.scala
deleted file mode 100644
index 04d0a6c759..0000000000
--- a/test/files/jvm/xmlmore.scala
+++ /dev/null
@@ -1,29 +0,0 @@
-object myBreak extends scala.xml.Unparsed("<br />")
-
-object Test extends App {
- val com = <!-- thissa comment -->
- val pi = <?this is a pi foo bar = && {{ ?>
- val crz = <![CDATA[
- "Come, come again, whoever you are, come!
-Heathen, fire worshipper or idolatrous, come!
-Come even if you broke your penitence a hundred times,
-Ours is the portal of hope, come as you are."
- Mevlana Celaleddin Rumi]]>
-
- val nazim = <foo>{myBreak}</foo> // shows use of unparsed
-
- Console println com
- Console println pi
- Console println crz // this guy will escaped, and rightly so
- Console println nazim
- Console println "End Test"
-
- <x:foo xmlns:x="gaga"/> match {
- case scala.xml.QNode("gaga","foo",md,child@_*) =>
- }
-
- <x:foo xmlns:x="gaga"/> match {
- case scala.xml.Node("foo",md,child@_*) =>
- }
-
-}
diff --git a/test/files/jvm/xmlpull.scala b/test/files/jvm/xmlpull.scala
deleted file mode 100644
index 9ba7d4cf02..0000000000
--- a/test/files/jvm/xmlpull.scala
+++ /dev/null
@@ -1,31 +0,0 @@
-import scala.xml._
-import scala.xml.pull._
-import scala.io.Source
-
-object Test {
-
- val src = Source.fromString("<hello><world/>!</hello>")
-
- def main(args: Array[String]) {
- var er = new XMLEventReader(src)
- er.next match {
- case EvElemStart(_, "hello", _, _) => //println("1")
- }
- er.next match {
- case EvElemStart(_, "world", _, _) => //println("2")
- }
- er.next match {
- case EvElemEnd(_, "world") => //println("3")
- }
- er.next match {
- case EvText("!") => //println("4")
- }
- er.next match {
- case EvElemEnd(_, "hello") => //println("5")
- }
- // you get the picture...
- er.stop // allow thread to be garbage-collected
- //println("6")
- }
-}
-
diff --git a/test/files/jvm/xmlstuff.check b/test/files/jvm/xmlstuff.check
deleted file mode 100644
index e1222479f7..0000000000
--- a/test/files/jvm/xmlstuff.check
+++ /dev/null
@@ -1,22 +0,0 @@
-NodeSeq
-<result>
- <title>Blabla</title>
- <remarks> Hallo Welt. </remarks>
-</result><result>
- <title>Blubabla</title>
- <remarks> Hello Blu </remarks>
-</result><result>
- <title>Blubabla</title>
- <remarks> rem 2 </remarks>
-</result>
-List(<book><title>Blabla</title></book>)
-<result>
- <name>John</name>
- <street> Elm Street</street>
- <city>Dolphin City</city>
- <phone where="work"> +41 21 693 68 67</phone>
- <phone where="mobile">+41 79 602 23 23</phone>
-</result>
-namespaces
-validation - elements
-validation - attributes
diff --git a/test/files/jvm/xmlstuff.scala b/test/files/jvm/xmlstuff.scala
deleted file mode 100644
index 45234c7139..0000000000
--- a/test/files/jvm/xmlstuff.scala
+++ /dev/null
@@ -1,181 +0,0 @@
-import java.io.StringReader
-import org.xml.sax.InputSource
-import scala.xml.{Node, NodeSeq, Elem, Text, XML}
-
-object Test {
-
- /** returns true if exception was thrown */
- def catcher(att: Function1[Unit, scala.xml.MetaData]): Boolean = {
- var ex = false
- try {
- att.apply({})
- } catch {
- case scala.xml.MalformedAttributeException(msg) =>
- println(msg)
- ex = true
- }
- ex
- }
-
- def main(args: Array[String]) {
-
- println("NodeSeq")
-
- val p = <foo>
- <bar gt='ga' value="3"/>
- <baz bazValue="8"/>
- <bar value="5" gi='go'/>
- </foo>;
-
- val pelems_1 = for (x <- p \ "bar"; y <- p \ "baz" ) yield {
- Text(x.attributes("value").toString + y.attributes("bazValue").toString+ "!")
- };
- val pelems_2 = new NodeSeq { val theSeq = List(Text("38!"),Text("58!")) };
- assert(pelems_1 sameElements pelems_2)
-
- assert(Text("8") sameElements (p \\ "@bazValue"))
-
- val books =
- <bks>
- <book><title>Blabla</title></book>
- <book><title>Blubabla</title></book>
- <book><title>Baaaaaaalabla</title></book>
- </bks>;
-
- val reviews =
- <reviews>
- <entry><title>Blabla</title>
- <remarks>
- Hallo Welt.
- </remarks>
- </entry>
- <entry><title>Blubabla</title>
- <remarks>
- Hello Blu
- </remarks>
- </entry>
- <entry><title>Blubabla</title>
- <remarks>
- rem 2
- </remarks>
- </entry>
- </reviews>;
-
- println( new scala.xml.PrettyPrinter(80, 5).formatNodes (
- for (t <- books \\ "title";
- r <- reviews \\ "entry"
- if (r \ "title") xml_== t) yield
- <result>
- { t }
- { r \ "remarks" }
- </result>
- ));
-
- // example
- println(
- for (t @ <book><title>Blabla</title></book> <- new NodeSeq { val theSeq = books.child }.toList)
- yield t
- );
- val phoneBook =
- <phonebook>
- <descr>
- This is the <b>phonebook</b> of the
- <a href="http://acme.org">ACME</a> corporation.
- </descr>
- <entry>
- <name>John</name>
- <phone where="work"> +41 21 693 68 67</phone>
- <phone where="mobile">+41 79 602 23 23</phone>
- </entry>
- </phonebook>;
-
-
- val addrBook =
- <addrbook>
- <descr>
- This is the <b>addressbook</b> of the
- <a href="http://acme.org">ACME</a> corporation.
- </descr>
- <entry>
- <name>John</name>
- <street> Elm Street</street>
- <city>Dolphin City</city>
- </entry>
- </addrbook>;
-
- println( new scala.xml.PrettyPrinter(80, 5).formatNodes (
- for (t <- addrBook \\ "entry";
- r <- phoneBook \\ "entry"
- if (t \ "name") xml_== (r \ "name")) yield
- <result>
- { t.child }
- { r \ "phone" }
- </result>
- ));
-
-
- /* namespaces */
- // begin tmp
- println("namespaces")
- val cuckoo = <cuckoo xmlns="http://cuckoo.com">
- <foo/>
- <bar/>
- </cuckoo>;
- assert(cuckoo.namespace == "http://cuckoo.com")
- for (n <- cuckoo \ "_" ) {
- //println("n = "+n);
- //println("n.prefix = "+n.prefix);
- //.println("n.scope = "+n.scope);
- assert( n.namespace == "http://cuckoo.com")
- }
-
- println("validation - elements")
- val vtor = new scala.xml.dtd.ElementValidator();
- {
- import scala.xml.dtd.ELEMENTS
- import scala.xml.dtd.ContentModel._
- vtor.setContentModel(
- ELEMENTS(
- Sequ(
- Letter(ElemName("bar")),
- Star(Letter(ElemName("baz"))) )));
-
- }
- assert(vtor( <foo><bar/><baz/><baz/></foo> ))
-
- {
- import scala.xml.dtd.MIXED
- import scala.xml.dtd.ContentModel._
-
- vtor.setContentModel(
- MIXED(
- Alt(Letter(ElemName("bar")),
- Letter(ElemName("baz")),
- Letter(ElemName("bal")))));
- }
-
- assert(vtor(<foo><bar/><baz/><baz/></foo> ))
- assert(vtor(<foo>ab<bar/>cd<baz/>ed<baz/>gh</foo> ))
- assert(!vtor(<foo> <ugha/> <bugha/> </foo> ))
-
- println("validation - attributes")
- vtor.setContentModel(null)
- vtor.setMetaData(List())
- assert(!vtor( <foo bar="hello"/> ))
-
- {
- import scala.xml.dtd._
- vtor setMetaData List(AttrDecl("bar", "CDATA", IMPLIED))
- }
- assert(!vtor(<foo href="http://foo.com" bar="hello"/>))
- assert(vtor(<foo bar="hello"/>))
-
- {
- import scala.xml.dtd._
- vtor.setMetaData(List(AttrDecl("bar","CDATA",REQUIRED)))
- }
- assert(!vtor( <foo href="http://foo.com" /> ))
- assert( vtor( <foo bar="http://foo.com" /> ))
-
- }
-}