|
| 1 | +import org.scalacheck._, Prop._, Gen._, Arbitrary._ |
| 2 | +import scala.reflect.runtime.universe._, Flag._ |
| 3 | + |
| 4 | +object RuntimeErrorProps extends QuasiquoteProperties("errors") { |
| 5 | + def testFails[T](block: =>T) = test { |
| 6 | + assertThrows[IllegalArgumentException] { |
| 7 | + block |
| 8 | + } |
| 9 | + } |
| 10 | + |
| 11 | + property("default param anon function") = testFails { |
| 12 | + val param = q"val x: Int = 1" |
| 13 | + q"{ $param => x + 1 }" |
| 14 | + } |
| 15 | + |
| 16 | + property("non-casedef case") = testFails { |
| 17 | + val x = q"x" |
| 18 | + q"foo match { case $x }" |
| 19 | + } |
| 20 | + |
| 21 | + property("non-new annotation") = testFails { |
| 22 | + val annot = q"foo" |
| 23 | + q"@$annot def foo" |
| 24 | + } |
| 25 | + |
| 26 | + property("non-valdef param") = testFails { |
| 27 | + val param = q"foo" |
| 28 | + q"def foo($param)" |
| 29 | + } |
| 30 | + |
| 31 | + property("non-valdef class param") = testFails { |
| 32 | + val param = q"foo" |
| 33 | + q"class Foo($param)" |
| 34 | + } |
| 35 | + |
| 36 | + property("non-typedef type param") = testFails { |
| 37 | + val tparam = tq"T" |
| 38 | + q"class C[$tparam]" |
| 39 | + } |
| 40 | + |
| 41 | + property("non-definition refine stat") = testFails { |
| 42 | + val stat = q"foo" |
| 43 | + tq"Foo { $stat }" |
| 44 | + } |
| 45 | + |
| 46 | + property("non-definition early def") = testFails { |
| 47 | + val stat = q"foo" |
| 48 | + q"class Foo extends { $stat } with Bar" |
| 49 | + } |
| 50 | + |
| 51 | + property("type apply for definition") = testFails { |
| 52 | + val defn = q"def foo" |
| 53 | + q"$defn[foo]" |
| 54 | + } |
| 55 | + |
| 56 | + property("non-val selftype") = testFails { |
| 57 | + val foo = q"foo" |
| 58 | + q"class Foo { $foo => }" |
| 59 | + } |
| 60 | + |
| 61 | + property("for empty enums") = testFails { |
| 62 | + val enums = List.empty[Tree] |
| 63 | + q"for(..$enums) 0" |
| 64 | + } |
| 65 | + |
| 66 | + property("for starts with non-from enum") = testFails { |
| 67 | + val enums = fq"foo = bar" :: Nil |
| 68 | + q"for(..$enums) 0" |
| 69 | + } |
| 70 | + |
| 71 | + property("for inlalid enum") = testFails { |
| 72 | + val enums = q"foo" :: Nil |
| 73 | + q"for(..$enums) 0" |
| 74 | + } |
| 75 | +} |
0 commit comments