aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/scala/async/neg/NakedAwait.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/scala/scala/async/neg/NakedAwait.scala')
-rw-r--r--src/test/scala/scala/async/neg/NakedAwait.scala72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/test/scala/scala/async/neg/NakedAwait.scala b/src/test/scala/scala/async/neg/NakedAwait.scala
index db67f18..66bc947 100644
--- a/src/test/scala/scala/async/neg/NakedAwait.scala
+++ b/src/test/scala/scala/async/neg/NakedAwait.scala
@@ -16,4 +16,76 @@ class NakedAwait {
""".stripMargin
}
}
+
+
+ @Test
+ def `await not allowed in by-name argument`() {
+ expectError("await must not be used under a by-name argument.") {
+ """
+ | import _root_.scala.async.AsyncId._
+ | def foo(a: Int)(b: => Int) = 0
+ | async { foo(0)(await(0)) }
+ """.stripMargin
+ }
+ }
+
+ @Test
+ def `await not allowed in boolean short circuit argument 1`() {
+ expectError("await must not be used under a by-name argument.") {
+ """
+ | import _root_.scala.async.AsyncId._
+ | async { true && await(false) }
+ """.stripMargin
+ }
+ }
+
+ @Test
+ def `await not allowed in boolean short circuit argument 2`() {
+ expectError("await must not be used under a by-name argument.") {
+ """
+ | import _root_.scala.async.AsyncId._
+ | async { true || await(false) }
+ """.stripMargin
+ }
+ }
+
+ @Test
+ def nestedObject() {
+ expectError("await must not be used under a nested object.") {
+ """
+ | import _root_.scala.async.AsyncId._
+ | async { object Nested { await(false) } }
+ """.stripMargin
+ }
+ }
+
+ @Test
+ def nestedTrait() {
+ expectError("await must not be used under a nested trait.") {
+ """
+ | import _root_.scala.async.AsyncId._
+ | async { trait Nested { await(false) } }
+ """.stripMargin
+ }
+ }
+
+ @Test
+ def nestedClass() {
+ expectError("await must not be used under a nested class.") {
+ """
+ | import _root_.scala.async.AsyncId._
+ | async { class Nested { await(false) } }
+ """.stripMargin
+ }
+ }
+
+ @Test
+ def nestedFunction() {
+ expectError("await must not be used under a nested anonymous function.") {
+ """
+ | import _root_.scala.async.AsyncId._
+ | async { () => { await(false) } }
+ """.stripMargin
+ }
+ }
}