diff options
Diffstat (limited to 'test/files/scalacheck/quasiquotes')
4 files changed, 59 insertions, 9 deletions
diff --git a/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala b/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala index fdb0d83277..69aef12668 100644 --- a/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala @@ -9,7 +9,7 @@ object DefinitionConstructionProps with ValDefConstruction with PatDefConstruction with DefConstruction - with PackageConstruction + with PackageConstruction with ImportConstruction { val x: Tree = q"val x: Int" @@ -81,6 +81,15 @@ trait ClassConstruction { self: QuasiquoteProperties => assertEqAst(q" class C($privx)", " class C(x: Int) ") assertEqAst(q"case class C($privx)", "case class C(private[this] val x: Int)") } + + property("SI-8333") = test { + assertEqAst(q"{ $NoMods class C }", "{ class C }") + } + + property("SI-8332") = test { + val args = q"val a: Int; val b: Int" + assertEqAst(q"class C(implicit ..$args)", "class C(implicit val a: Int, val b: Int)") + } } trait TraitConstruction { self: QuasiquoteProperties => diff --git a/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala index 996ac65b36..af7f2164a0 100644 --- a/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala @@ -73,8 +73,11 @@ trait ClassDeconstruction { self: QuasiquoteProperties => property("exhaustive class matcher") = test { def matches(line: String) { - val q"""$classMods class $name[..$targs] $ctorMods(...$argss) - extends { ..$early } with ..$parents { $self => ..$body }""" = parse(line) + val tree = parse(line) + val q"""$classMods0 class $name0[..$targs0] $ctorMods0(...$argss0) + extends { ..$early0 } with ..$parents0 { $self0 => ..$body0 }""" = tree + val q"""$classMods1 class $name1[..$targs1] $ctorMods1(...$argss1)(implicit ..$impl) + extends { ..$early1 } with ..$parents1 { $self1 => ..$body1 }""" = tree } matches("class Foo") matches("class Foo[T]") @@ -106,6 +109,13 @@ trait ClassDeconstruction { self: QuasiquoteProperties => Ident(TypeName("Int")), EmptyTree))), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(()))))))) } } + + property("SI-8332") = test { + val q"class C(implicit ..$args)" = q"class C(implicit i: I, j: J)" + val q"$imods val i: I" :: q"$jmods val j: J" :: Nil = args + assert(imods.hasFlag(IMPLICIT)) + assert(jmods.hasFlag(IMPLICIT)) + } } trait ModsDeconstruction { self: QuasiquoteProperties => diff --git a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala index 10ce1604b1..fd4d2e9c4b 100644 --- a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala @@ -103,7 +103,7 @@ object TermConstructionProps extends QuasiquoteProperties("term construction") { def blockInvariant(quote: Tree, trees: List[Tree]) = quote ≈ (trees match { - case Nil => q"" + case Nil => q"{}" case _ :+ last if !last.isTerm => Block(trees, q"()") case head :: Nil => head case init :+ last => Block(init, last) @@ -277,11 +277,18 @@ object TermConstructionProps extends QuasiquoteProperties("term construction") { assert(stats ≈ List(q"def x = 2", q"()")) } - property("empty-tree as block") = test { - val q"{ ..$stats1 }" = q" " - assert(stats1.isEmpty) - val stats2 = List.empty[Tree] - assert(q"{ ..$stats2 }" ≈ q"") + property("empty-tree is not a block") = test { + assertThrows[MatchError] { + val q"{ ..$stats1 }" = q" " + } + } + + property("empty block is synthetic unit") = test { + val q"()" = q"{}" + val q"{..$stats}" = q"{}" + assert(stats.isEmpty) + assertEqAst(q"{..$stats}", "{}") + assertEqAst(q"{..$stats}", "()") } property("consistent variable order") = test { diff --git a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala index 7c9b5ead20..e96d1186f7 100644 --- a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala @@ -175,4 +175,28 @@ object TermDeconstructionProps extends QuasiquoteProperties("term deconstruction assert(x ≈ q"x") val q"{ _ * _ }" = q"{ _ * _ }" } + + property("si-8275 a") = test { + val cq"_ => ..$stats" = cq"_ => foo; bar" + assert(stats ≈ List(q"foo", q"bar")) + } + + property("si-8275 b") = test { + val cq"_ => ..$init; $last" = cq"_ => a; b; c" + assert(init ≈ List(q"a", q"b")) + assert(last ≈ q"c") + } + + property("si-8275 c") = test { + val cq"_ => ..$stats" = cq"_ =>" + assert(stats.isEmpty) + assertEqAst(q"{ case _ => ..$stats }", "{ case _ => }") + } + + property("can't flatten type into block") = test { + assertThrows[IllegalArgumentException] { + val tpt = tq"List[Int]" + q"..$tpt; ()" + } + } } |