diff options
Diffstat (limited to 'test/files/scalacheck')
4 files changed, 52 insertions, 0 deletions
diff --git a/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala b/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala index 69aef12668..fd810674f5 100644 --- a/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala @@ -90,6 +90,15 @@ trait ClassConstruction { self: QuasiquoteProperties => val args = q"val a: Int; val b: Int" assertEqAst(q"class C(implicit ..$args)", "class C(implicit val a: Int, val b: Int)") } + + property("SI-8451: inline secondary constructors") = test { + assertEqAst(q"class C(x: Int) { def this() = this(0) }", "class C(x: Int) { def this() = this(0) }") + } + + property("SI-8451: unquoted secondary constructors") = test { + val secondaryCtor = q"def this() = this(0)" + assertEqAst(q"class C(x: Int) { $secondaryCtor }", "class C(x: Int) { def this() = this(0) }") + } } trait TraitConstruction { self: QuasiquoteProperties => diff --git a/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala index af7f2164a0..2c0e100b5a 100644 --- a/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/DefinitionDeconstructionProps.scala @@ -229,6 +229,12 @@ trait DefDeconstruction { self: QuasiquoteProperties => val q"def foo(...$argss)(implicit ..$impl)" = q"def foo(x: Int)" assert(impl.isEmpty) } + + property("SI-8451") = test { + val q"def this(..$params) = this(..$args)" = q"def this(x: Int) = this(0)" + assert(params ≈ List(q"${Modifiers(PARAM)} val x: Int")) + assert(args ≈ List(q"0")) + } } trait ImportDeconstruction { self: QuasiquoteProperties => diff --git a/test/files/scalacheck/quasiquotes/ErrorProps.scala b/test/files/scalacheck/quasiquotes/ErrorProps.scala index 9137fe17d8..2cba07abf2 100644 --- a/test/files/scalacheck/quasiquotes/ErrorProps.scala +++ b/test/files/scalacheck/quasiquotes/ErrorProps.scala @@ -195,6 +195,19 @@ object ErrorProps extends QuasiquoteProperties("errors") { q"f(..$l)" """) + property("SI-8451 construction: disallow everything except for constructor calls in secondary constructor bodies") = fails( + "'this' expected but unquotee found", + """ + val rhs1 = q"this(0)" + val ctor1 = q"def this(x: Int) = $rhs1" + """) + + property("SI-8451 deconstruction: disallow everything except for constructor calls in secondary constructor bodies") = fails( + "'this' expected but unquotee found", + """ + val q"def this(..$params) = $rhs2" = q"def this(x: Int) = this(0)" + """) + // // Make sure a nice error is reported in this case // { import Flag._; val mods = NoMods; q"lazy $mods val x: Int" } } diff --git a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala index 9e60729c09..49ffaff630 100644 --- a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala @@ -222,4 +222,28 @@ object TermDeconstructionProps extends QuasiquoteProperties("term deconstruction val q"{ case ..$cases }" = q"{ case a => b case c => d }" val List(cq"a => b", cq"c => d") = cases } + + property("SI-8350 `new C` and `new C()` are equivalent") = test { + val q"new C" = q"new C()" + val q"new C()" = q"new C" + } + + property("SI-8350 new applications extracted only for non-empty ctor calls") = test{ + val q"new $c1" = q"new C()" + assert(c1 ≈ tq"C") + val q"new $c2" = q"new C(x)" + assert(c2 ≈ q"${tq"C"}(x)") + } + + property("SI-8350 original test case") = test { + val q"new ..$parents" = q"new Foo with Bar" + assert(parents ≈ List(tq"Foo", tq"Bar")) + } + + property("SI-8387 new is not an application") = test { + val `new` = q"new F(x)" + val q"$f(...$argss)" = `new` + assert(f ≈ `new`) + assert(argss.isEmpty) + } } |