summaryrefslogtreecommitdiff
path: root/test/files/scalacheck
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2014-02-16 16:58:28 +0100
committerEugene Burmako <xeno.by@gmail.com>2014-02-16 19:25:38 +0100
commit862f7709cdabd82327ca0f37a480884c88f96be7 (patch)
tree688717816eeee19ddb391f1009c82d9b6f09f224 /test/files/scalacheck
parent2fc0164a5e777a0495c1801d8d38d60158ec2a77 (diff)
parent6ef6c96eff2f0d2f505d45a1436d73a960193076 (diff)
downloadscala-862f7709cdabd82327ca0f37a480884c88f96be7.tar.gz
scala-862f7709cdabd82327ca0f37a480884c88f96be7.tar.bz2
scala-862f7709cdabd82327ca0f37a480884c88f96be7.zip
Merge remote-tracking branch 'origin/master' into topic/palladium0
Conflicts: src/compiler/scala/reflect/macros/compiler/Resolvers.scala src/compiler/scala/reflect/macros/contexts/Typers.scala src/compiler/scala/tools/reflect/ToolBoxFactory.scala src/reflect/scala/reflect/api/BuildUtils.scala
Diffstat (limited to 'test/files/scalacheck')
-rw-r--r--test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala72
-rw-r--r--test/files/scalacheck/quasiquotes/LiftableProps.scala1
-rw-r--r--test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala2
-rw-r--r--test/files/scalacheck/quasiquotes/TermConstructionProps.scala5
-rw-r--r--test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala5
-rw-r--r--test/files/scalacheck/quasiquotes/TypeConstructionProps.scala5
-rw-r--r--test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala5
-rw-r--r--test/files/scalacheck/quasiquotes/UnliftableProps.scala2
8 files changed, 78 insertions, 19 deletions
diff --git a/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala b/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala
index 0e0e70fd62..7e846bfb24 100644
--- a/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/DefinitionConstructionProps.scala
@@ -7,21 +7,22 @@ object DefinitionConstructionProps
with TraitConstruction
with TypeDefConstruction
with ValDefConstruction
+ with PatDefConstruction
with DefConstruction
- with PackageConstruction
+ with PackageConstruction
with ImportConstruction {
- property("SI-6842") = test {
- val x: Tree = q"val x: Int"
- assertEqAst(q"def f($x) = 0", "def f(x: Int) = 0")
- assertEqAst(q"class C($x)", "class C(val x: Int)")
- assertEqAst(q"class C { $x => }", "class C { x: Int => }")
- assertEqAst(q"trait B { $x => }", "trait B { x: Int => }")
- assertEqAst(q"object A { $x => }", "object A { x: Int => }")
- val t: Tree = q"type T"
- assertEqAst(q"def f[$t] = 0", "def f[T] = 0")
- assertEqAst(q"class C[$t]", "class C[T]")
- assertEqAst(q"trait B[$t]", "trait B[T]")
- }
+
+ val x: Tree = q"val x: Int"
+ property("SI-6842 a1") = test { assertEqAst(q"def f($x) = 0", "def f(x: Int) = 0") }
+ property("SI-6842 a2") = test { assertEqAst(q"class C($x)", "class C(val x: Int)") }
+ property("SI-6842 a3") = test { assertEqAst(q"class C { $x => }", "class C { x: Int => }") }
+ property("SI-6842 a4") = test { assertEqAst(q"trait B { $x => }", "trait B { x: Int => }") }
+ property("SI-6842 a5") = test { assertEqAst(q"object A { $x => }", "object A { x: Int => }") }
+
+ val t: Tree = q"type T"
+ property("SI-6842 b1") = test { assertEqAst(q"def f[$t] = 0", "def f[T] = 0") }
+ property("SI-6842 b2") = test { assertEqAst(q"class C[$t]", "class C[T]") }
+ property("SI-6842 b3") = test { assertEqAst(q"trait B[$t]", "trait B[T]") }
}
trait ClassConstruction { self: QuasiquoteProperties =>
@@ -200,13 +201,54 @@ trait TypeDefConstruction { self: QuasiquoteProperties =>
}
trait ValDefConstruction { self: QuasiquoteProperties =>
- property("splice term name into val") = forAll { (name: TermName, tpt: Tree, rhs: Tree) =>
+ property("splice into val") = forAll { (name: TermName, tpt: Tree, rhs: Tree) =>
q"val $name: $tpt = $rhs" ≈ ValDef(Modifiers(), name, tpt, rhs)
}
- property("splice term name into var") = forAll { (name: TermName, tpt: Tree, rhs: Tree) =>
+ property("splice into var") = forAll { (name: TermName, tpt: Tree, rhs: Tree) =>
q"var $name: $tpt = $rhs" ≈ ValDef(Modifiers(MUTABLE), name, tpt, rhs)
}
+
+ // left tree is not a pattern due to Si-8211
+ property("SI-8202") = test {
+ assertEqAst(q"val (x: Int) = 1", "val x: Int = 1")
+ }
+}
+
+trait PatDefConstruction { self: QuasiquoteProperties =>
+ property("splice pattern into pat def") = test {
+ val pat = pq"(a, b)"
+ assertEqAst(q"val $pat = (1, 2)", "val (a, b) = (1, 2)")
+ val tpt = tq"(Int, Int)"
+ assertEqAst(q"val $pat: $tpt = (1, 2)", "val (a, b): (Int, Int) = (1, 2)")
+ }
+
+ property("splice pattern into pat def within other pattern (1)") = test {
+ val pat = pq"(a, b)"
+ assertEqAst(q"val Foo($pat) = Foo((1, 2))", "val Foo((a, b)) = Foo((1, 2))")
+ val tpt = tq"Foo"
+ assertEqAst(q"val Foo($pat): $tpt = Foo((1, 2))", "val Foo((a, b)): Foo = Foo((1, 2))")
+ }
+
+ property("splice patterns into pat def within other pattern (2)") = test {
+ val pat1 = pq"(a, b)"; val pat2 = pq"(c, d)"
+ assertEqAst(q"val ($pat1, $pat2) = ((1, 2), (3, 4))", "val ((a, b), (c, d)) = ((1, 2), (3, 4))")
+ val tpt = tq"((Int, Int), (Int, Int))"
+ assertEqAst(q"val ($pat1, $pat2): $tpt = ((1, 2), (3, 4))", "val ((a, b), (c, d)): ((Int, Int), (Int, Int)) = ((1, 2), (3, 4))")
+ }
+
+ property("splice pattern without free vars into pat def") = test {
+ val pat = pq"((1, 2), 3)"
+ assertEqAst(q"val $pat = ((1, 2), 3)", "{ val ((1, 2), 3) = ((1, 2), 3) }")
+ val tpt = tq"((Int, Int), Int)"
+ assertEqAst(q"val $pat: $tpt = ((1, 2), 3)","{ val ((1, 2), 3): ((Int, Int), Int) = ((1, 2), 3) }")
+ }
+
+ // won't result into pattern match due to SI-8211
+ property("splice typed pat into pat def") = test {
+ val pat = pq"x: Int"
+ assertEqAst(q"val $pat = 2", "{ val x: Int = 2 }")
+ }
}
trait MethodConstruction { self: QuasiquoteProperties =>
diff --git a/test/files/scalacheck/quasiquotes/LiftableProps.scala b/test/files/scalacheck/quasiquotes/LiftableProps.scala
index bd631b8734..20cfcbe139 100644
--- a/test/files/scalacheck/quasiquotes/LiftableProps.scala
+++ b/test/files/scalacheck/quasiquotes/LiftableProps.scala
@@ -99,7 +99,6 @@ object LiftableProps extends QuasiquoteProperties("liftable") {
}
property("lift tuple") = test {
- assert(q"${Tuple1(1)}" ≈ q"scala.Tuple1(1)")
assert(q"${(1, 2)}" ≈ q"(1, 2)")
assert(q"${(1, 2, 3)}" ≈ q"(1, 2, 3)")
assert(q"${(1, 2, 3, 4)}" ≈ q"(1, 2, 3, 4)")
diff --git a/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala b/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala
index 2600b0c120..6132244227 100644
--- a/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala
+++ b/test/files/scalacheck/quasiquotes/QuasiquoteProperties.scala
@@ -28,7 +28,7 @@ trait Helpers {
override def transform(tree: Tree): Tree = tree match {
case Ident(SimplifiedName(name)) => Ident(name)
- case ValDef(mods, SimplifiedName(name), tpt, rhs) => ValDef(mods, name, tpt, rhs)
+ case ValDef(mods, SimplifiedName(name), tpt, rhs) => ValDef(mods, name, transform(tpt), transform(rhs))
case Bind(SimplifiedName(name), rhs) => Bind(name, rhs)
case _ =>
super.transform(tree)
diff --git a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala
index 400e1ac9fd..4dbf746cfe 100644
--- a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala
@@ -139,6 +139,11 @@ object TermConstructionProps extends QuasiquoteProperties("term construction") {
assert(q"(..$empty)" ≈ q"()")
}
+ property("splice single element list into tuple") = test {
+ val xs = q"x" :: Nil
+ assert(q"(..$xs)" ≈ xs.head)
+ }
+
property("function param flags are the same") = test {
val xy = q"val x: A" :: q"val y: B" :: Nil
assertEqAst(q"(..$xy) => x + y", "(x: A, y: B) => x + y")
diff --git a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala
index 148bb383b0..7c9b5ead20 100644
--- a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala
@@ -82,6 +82,11 @@ object TermDeconstructionProps extends QuasiquoteProperties("term deconstruction
assert(last ≈ q"d")
}
+ property("deconstruct expr as tuple") = test {
+ val q"(..$elems)" = q"foo"
+ assert(elems ≈ List(q"foo"))
+ }
+
property("deconstruct cases") = test {
val q"$x match { case ..$cases }" = q"x match { case 1 => case 2 => }"
assert(x ≈ q"x")
diff --git a/test/files/scalacheck/quasiquotes/TypeConstructionProps.scala b/test/files/scalacheck/quasiquotes/TypeConstructionProps.scala
index ea9f734a0b..07875af326 100644
--- a/test/files/scalacheck/quasiquotes/TypeConstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/TypeConstructionProps.scala
@@ -18,6 +18,11 @@ object TypeConstructionProps extends QuasiquoteProperties("type construction")
assert(tq"(t0, ..$ts)" ≈ tq"scala.Tuple3[t0, t1, t2]")
}
+ property("single-element tuple type") = test {
+ val ts = q"T" :: Nil
+ assert(tq"(..$ts)" ≈ ts.head)
+ }
+
property("refined type") = test {
val stats = q"def foo" :: q"val x: Int" :: q"type Y = String" :: Nil
assert(tq"T { ..$stats }" ≈ tq"T { def foo; val x: Int; type Y = String }")
diff --git a/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala
index 0fdcc19052..8ec1779353 100644
--- a/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala
+++ b/test/files/scalacheck/quasiquotes/TypeDeconstructionProps.scala
@@ -35,6 +35,11 @@ object TypeDeconstructionProps extends QuasiquoteProperties("type deconstruction
assert(last ≈ tq"t2")
}
+ property("tuple type (5)") = test {
+ val tq"(..$ts)" = tq"T"
+ assert(ts ≈ List(tq"T"))
+ }
+
property("refined type") = test {
val tq"T { ..$stats }" = tq"T { def foo; val x: Int; type Y = String }"
assert(stats ≈ List(q"def foo", q"val x: Int", q"type Y = String"))
diff --git a/test/files/scalacheck/quasiquotes/UnliftableProps.scala b/test/files/scalacheck/quasiquotes/UnliftableProps.scala
index 8b827c98ff..4e996c90d7 100644
--- a/test/files/scalacheck/quasiquotes/UnliftableProps.scala
+++ b/test/files/scalacheck/quasiquotes/UnliftableProps.scala
@@ -111,8 +111,6 @@ object UnliftableProps extends QuasiquoteProperties("unliftable") {
}
property("unlift tuple") = test {
- // fails due to SI-8045
- // val q"${t1: Tuple1[Int]}" = q"_root_.scala.Tuple1(1)"
val q"${t2: (Int, Int)}" = q"(1, 2)"
val q"${t3: (Int, Int, Int)}" = q"(1, 2, 3)"
val q"${t4: (Int, Int, Int, Int)}" = q"(1, 2, 3, 4)"