diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/jvm/actor-uncaught-exception2.check | 2 | ||||
-rw-r--r-- | test/files/jvm/actor-uncaught-exception2.scala | 48 | ||||
-rw-r--r-- | test/files/neg/t3224.check | 6 | ||||
-rwxr-xr-x | test/files/neg/t3224.scala | 30 |
4 files changed, 86 insertions, 0 deletions
diff --git a/test/files/jvm/actor-uncaught-exception2.check b/test/files/jvm/actor-uncaught-exception2.check new file mode 100644 index 0000000000..870a5d32f9 --- /dev/null +++ b/test/files/jvm/actor-uncaught-exception2.check @@ -0,0 +1,2 @@ +UncaughtException(StartError,None,None,MyException: I don't want to run!) +UncaughtException(MessageError,Some('ping),Some(Supervisor),MyException: No message for me!) diff --git a/test/files/jvm/actor-uncaught-exception2.scala b/test/files/jvm/actor-uncaught-exception2.scala new file mode 100644 index 0000000000..973cfb370a --- /dev/null +++ b/test/files/jvm/actor-uncaught-exception2.scala @@ -0,0 +1,48 @@ +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() { + throw new MyException("I don't want to run!") + } + } + + case object MessageError extends Actor { + def act() { + react { + case _ => throw new MyException("No message for me!") + } + } + } + + case object Supervisor extends Actor { + def act() { + trapExit = true + link(StartError) + link(MessageError) + StartError.start() + MessageError.start() + + Actor.loop { + react { + case Exit(actor, reason) => + println(reason) + if (actor == StartError) + MessageError ! 'ping + else + exit() + } + } + } + } + + def main(args: Array[String]) { + Debug.level = 1 // decrease level so that it does not print warnings + Supervisor.start() + } +} diff --git a/test/files/neg/t3224.check b/test/files/neg/t3224.check new file mode 100644 index 0000000000..29304c567a --- /dev/null +++ b/test/files/neg/t3224.check @@ -0,0 +1,6 @@ +t3224.scala:29: error: polymorphic expression cannot be instantiated to expected type; + found : [T]Array[T] + required: List[?] + println(Texts textL Array()); println(Texts textL Array(1)); println(Texts textL Array(1, 1)) + ^ +one error found diff --git a/test/files/neg/t3224.scala b/test/files/neg/t3224.scala new file mode 100755 index 0000000000..0e24baf28a --- /dev/null +++ b/test/files/neg/t3224.scala @@ -0,0 +1,30 @@ +object Texts{ + def textL[T](list: List[T]) = { + list match{ + case List() => "Empty" + case List(_) => "One" + case List(_*) => "Many" + } + } + + def textA[T](array: Array[T]) = { + array match{ + case Array() => "Empty" + case Array(_) => "One" + case Array(_*) => "Many" + } + } +} + +object Test extends Application { + + implicit def array2list[T](array: Array[T]) = { + println(array.toList.size) + array.toList + } + + + println(Texts textL List()); println(Texts textL List(1)); println(Texts textL List(1, 1)); + + println(Texts textL Array()); println(Texts textL Array(1)); println(Texts textL Array(1, 1)) +} |