Skip to content

Commit bf0095d

Browse files
committed
Add test
1 parent 151bf8a commit bf0095d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/neg/i7060.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
object PostConditions1 {
2+
3+
import PostConditions.{ensure, res, Box}
4+
5+
val v = List(1, 2, 4).sum.ensure(Box(10) => res == 10) // error: not a legal formal parameter
6+
println(v)
7+
}
8+
9+
object PostConditions {
10+
11+
class Box[T](val t: T)
12+
13+
def res[T] given (b: Box[T]): T = b.t
14+
15+
def (e: T) ensure[T](cond: given Box[T] => Boolean): T = {
16+
if (cond given Box(e)) e
17+
else throw new AssertionError("condition not fulfilled")
18+
}
19+
}

0 commit comments

Comments
 (0)