diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/jvm/future-spec/FutureTests.scala | 2 | ||||
-rw-r--r-- | test/files/jvm/future-spec/PromiseTests.scala | 2 | ||||
-rw-r--r-- | test/files/jvm/scala-concurrent-tck.scala | 96 | ||||
-rw-r--r-- | test/files/neg/t5544.check | 4 | ||||
-rw-r--r-- | test/files/neg/t5544/Api_1.scala | 8 | ||||
-rw-r--r-- | test/files/neg/t5544/Test_2.scala | 3 | ||||
-rw-r--r-- | test/files/run/t4138.check | 2 | ||||
-rw-r--r-- | test/files/run/t4138.scala | 6 | ||||
-rw-r--r-- | test/files/run/t5544.check | 1 | ||||
-rw-r--r-- | test/files/run/t5544/Api_1.scala | 8 | ||||
-rw-r--r-- | test/files/run/t5544/Test_2.scala | 3 |
11 files changed, 123 insertions, 12 deletions
diff --git a/test/files/jvm/future-spec/FutureTests.scala b/test/files/jvm/future-spec/FutureTests.scala index 9a9cf951bb..e5e01a5954 100644 --- a/test/files/jvm/future-spec/FutureTests.scala +++ b/test/files/jvm/future-spec/FutureTests.scala @@ -19,7 +19,7 @@ object FutureTests extends MinimalScalaTest { case "NoReply" => Promise[String]().future } - val defaultTimeout = Inf + val defaultTimeout = 5 seconds /* future specification */ diff --git a/test/files/jvm/future-spec/PromiseTests.scala b/test/files/jvm/future-spec/PromiseTests.scala index 6016746a23..bf9d9b39d7 100644 --- a/test/files/jvm/future-spec/PromiseTests.scala +++ b/test/files/jvm/future-spec/PromiseTests.scala @@ -133,7 +133,7 @@ object PromiseTests extends MinimalScalaTest { (future, result) => intercept[NoSuchElementException] { Await.result(future.failed, defaultTimeout) - }.getMessage mustBe ("Future.failed not completed with a throwable. Instead completed with: " + result) + }.getMessage mustBe ("Future.failed not completed with a throwable.") } } diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala index fce1a25bb6..86655ad89c 100644 --- a/test/files/jvm/scala-concurrent-tck.scala +++ b/test/files/jvm/scala-concurrent-tck.scala @@ -182,6 +182,72 @@ trait FutureCombinators extends TestBase { } } + def testMapSuccessPF(): Unit = once { + done => + val f = future { 5 } + val g = f map { case r => "result: " + r } + g onSuccess { + case s => + done() + assert(s == "result: 5") + } + g onFailure { + case _ => + done() + assert(false) + } + } + + def testTransformSuccess(): Unit = once { + done => + val f = future { 5 } + val g = f.transform(r => "result: " + r, identity) + g onSuccess { + case s => + done() + assert(s == "result: 5") + } + g onFailure { + case _ => + done() + assert(false) + } + } + + def testTransformSuccessPF(): Unit = once { + done => + val f = future { 5 } + val g = f.transform( { case r => "result: " + r }, identity) + g onSuccess { + case s => + done() + assert(s == "result: 5") + } + g onFailure { + case _ => + done() + assert(false) + } + } + + def testFoldFailure(): Unit = once { + done => + val f = future { + throw new Exception("exception message") + } + val g = f.transform(r => "result: " + r, identity) + g onSuccess { + case _ => + done() + assert(false) + } + g onFailure { + case t => + done() + assert(t.getMessage() == "exception message") + } + } + def testFlatMapSuccess(): Unit = once { done => val f = future { 5 } @@ -340,14 +406,17 @@ trait FutureCombinators extends TestBase { } recover { case re: RuntimeException => "recovered" - } onSuccess { + } + f onSuccess { case x => done() assert(x == "recovered") - } onFailure { case any => + } + f onFailure { case any => done() assert(false) } + f } def testRecoverFailure(): Unit = once { @@ -357,11 +426,13 @@ trait FutureCombinators extends TestBase { throw cause } recover { case te: TimeoutException => "timeout" - } onSuccess { + } + f onSuccess { case x => done() assert(false) - } onFailure { case any => + } + f onFailure { case any => done() assert(any == cause) } @@ -375,11 +446,13 @@ trait FutureCombinators extends TestBase { } recoverWith { case re: RuntimeException => future { "recovered" } - } onSuccess { + } + f onSuccess { case x => done() assert(x == "recovered") - } onFailure { case any => + } + f onFailure { case any => done() assert(false) } @@ -393,11 +466,13 @@ trait FutureCombinators extends TestBase { } recoverWith { case te: TimeoutException => future { "timeout" } - } onSuccess { + } + f onSuccess { case x => done() assert(false) - } onFailure { case any => + } + f onFailure { case any => done() assert(any == cause) } @@ -635,11 +710,12 @@ trait Promises extends TestBase { val p = promise[Int]() val f = p.future - f.onSuccess { + f onSuccess { case x => done() assert(x == 5) - } onFailure { + } + f onFailure { case any => done() assert(false) diff --git a/test/files/neg/t5544.check b/test/files/neg/t5544.check new file mode 100644 index 0000000000..d4113935a3 --- /dev/null +++ b/test/files/neg/t5544.check @@ -0,0 +1,4 @@ +Test_2.scala:2: error: value baz is not a member of object Api + Api.baz + ^ +one error found diff --git a/test/files/neg/t5544/Api_1.scala b/test/files/neg/t5544/Api_1.scala new file mode 100644 index 0000000000..77637f440a --- /dev/null +++ b/test/files/neg/t5544/Api_1.scala @@ -0,0 +1,8 @@ +import scala.annotation.StaticAnnotation + +class ann(val bar: Any) extends StaticAnnotation + +object Api { + @ann({def baz = "baz!!"}) + def foo = println("foo") +} diff --git a/test/files/neg/t5544/Test_2.scala b/test/files/neg/t5544/Test_2.scala new file mode 100644 index 0000000000..4c8c99cbc7 --- /dev/null +++ b/test/files/neg/t5544/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + Api.baz +} diff --git a/test/files/run/t4138.check b/test/files/run/t4138.check new file mode 100644 index 0000000000..f561b5e6b0 --- /dev/null +++ b/test/files/run/t4138.check @@ -0,0 +1,2 @@ +[1.45] parsed: "lir 'de\' ' \\ \n / upa \"new\" \t parsing" +[1.5] parsed: "s " diff --git a/test/files/run/t4138.scala b/test/files/run/t4138.scala new file mode 100644 index 0000000000..131489e581 --- /dev/null +++ b/test/files/run/t4138.scala @@ -0,0 +1,6 @@ +object Test extends App { + object p extends scala.util.parsing.combinator.JavaTokenParsers + + println(p.parse(p.stringLiteral, """"lir 'de\' ' \\ \n / upa \"new\" \t parsing"""")) + println(p.parse(p.stringLiteral, """"s " lkjse"""")) +} diff --git a/test/files/run/t5544.check b/test/files/run/t5544.check new file mode 100644 index 0000000000..257cc5642c --- /dev/null +++ b/test/files/run/t5544.check @@ -0,0 +1 @@ +foo diff --git a/test/files/run/t5544/Api_1.scala b/test/files/run/t5544/Api_1.scala new file mode 100644 index 0000000000..b4c92864de --- /dev/null +++ b/test/files/run/t5544/Api_1.scala @@ -0,0 +1,8 @@ +import scala.annotation.StaticAnnotation + +class ann(val bar: Any) extends StaticAnnotation + +object Api { + @ann({def foo = "foo!!"}) + def foo = println("foo") +} diff --git a/test/files/run/t5544/Test_2.scala b/test/files/run/t5544/Test_2.scala new file mode 100644 index 0000000000..285f8959e0 --- /dev/null +++ b/test/files/run/t5544/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + Api.foo +} |