summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-09-16 03:06:34 -0700
committerJason Zaugg <jzaugg@gmail.com>2013-09-16 03:06:34 -0700
commit9dbc321504ad5550638d6d7c2b3cd2f98273cf74 (patch)
tree7459704f5c9f0d471e63ec56b4f15c2803f10a59 /test/files
parent8c68723acd738d94d049ac996d5e0ea22659c4ba (diff)
parent8a7b5666b6f10728f7c3ae9ca1bc2a8b82f6b965 (diff)
downloadscala-9dbc321504ad5550638d6d7c2b3cd2f98273cf74.tar.gz
scala-9dbc321504ad5550638d6d7c2b3cd2f98273cf74.tar.bz2
scala-9dbc321504ad5550638d6d7c2b3cd2f98273cf74.zip
Merge pull request #2935 from densh/topic/si-7304-6489-6701
SI-6701, SI-7304, SI-6489, variable arity definitions refactoring
Diffstat (limited to 'test/files')
-rw-r--r--test/files/run/macro-parse-position-malformed.check1
-rw-r--r--test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala17
-rw-r--r--test/files/run/macro-parse-position-malformed/Test_2.scala3
-rw-r--r--test/files/run/macro-parse-position.check5
-rw-r--r--test/files/run/macro-parse-position/Impls_Macros_1.scala12
-rw-r--r--test/files/run/macro-parse-position/Test_2.scala3
-rw-r--r--test/files/run/reify_copypaste1.scala2
-rw-r--r--test/files/scalacheck/quasiquotes/DeprecationProps.scala52
-rw-r--r--test/files/scalacheck/quasiquotes/Test.scala3
9 files changed, 96 insertions, 2 deletions
diff --git a/test/files/run/macro-parse-position-malformed.check b/test/files/run/macro-parse-position-malformed.check
new file mode 100644
index 0000000000..00f0bc5b62
--- /dev/null
+++ b/test/files/run/macro-parse-position-malformed.check
@@ -0,0 +1 @@
+failed with 'source-<macro>,line-1,offset=7' position and '')' expected but eof found.' message
diff --git a/test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala b/test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala
new file mode 100644
index 0000000000..2417eb6897
--- /dev/null
+++ b/test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala
@@ -0,0 +1,17 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.{Context => Ctx, ParseException}
+
+object Macros {
+ def impl(c: Ctx)() = {
+ import c.universe._
+ val out = try {
+ c.parse("foo(bar")
+ "didn't fail"
+ } catch {
+ case e: ParseException =>
+ s"failed with '${e.pos}' position and '${e.msg}' message"
+ }
+ c.Expr[String](Literal(Constant(out)))
+ }
+ def foo(): String = macro impl
+} \ No newline at end of file
diff --git a/test/files/run/macro-parse-position-malformed/Test_2.scala b/test/files/run/macro-parse-position-malformed/Test_2.scala
new file mode 100644
index 0000000000..cff569bd81
--- /dev/null
+++ b/test/files/run/macro-parse-position-malformed/Test_2.scala
@@ -0,0 +1,3 @@
+object Test extends App {
+ println(Macros.foo)
+}
diff --git a/test/files/run/macro-parse-position.check b/test/files/run/macro-parse-position.check
new file mode 100644
index 0000000000..3da0320696
--- /dev/null
+++ b/test/files/run/macro-parse-position.check
@@ -0,0 +1,5 @@
+false
+source-<macro>,line-1,offset=4
+8
+foo bar
+
diff --git a/test/files/run/macro-parse-position/Impls_Macros_1.scala b/test/files/run/macro-parse-position/Impls_Macros_1.scala
new file mode 100644
index 0000000000..b6f1ebbcd5
--- /dev/null
+++ b/test/files/run/macro-parse-position/Impls_Macros_1.scala
@@ -0,0 +1,12 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.{Context => Ctx}
+
+object Macros {
+ def impl(c: Ctx)() = {
+ import c.universe._
+ val t = c.parse("foo bar")
+ val out = s"${t.pos == NoPosition}\n${t.pos}\n${t.pos.source.content.length}\n${new String(t.pos.source.content)}"
+ c.Expr[String](Literal(Constant(out)))
+ }
+ def foo(): String = macro impl
+} \ No newline at end of file
diff --git a/test/files/run/macro-parse-position/Test_2.scala b/test/files/run/macro-parse-position/Test_2.scala
new file mode 100644
index 0000000000..cff569bd81
--- /dev/null
+++ b/test/files/run/macro-parse-position/Test_2.scala
@@ -0,0 +1,3 @@
+object Test extends App {
+ println(Macros.foo)
+}
diff --git a/test/files/run/reify_copypaste1.scala b/test/files/run/reify_copypaste1.scala
index b2eef28026..cf813182ae 100644
--- a/test/files/run/reify_copypaste1.scala
+++ b/test/files/run/reify_copypaste1.scala
@@ -12,7 +12,7 @@ object Test extends App {
val reify = Select(Select(Select(Select(Ident(ScalaPackage), TermName("reflect")), TermName("runtime")), TermName("universe")), TermName("reify"))
val reifee = Block(List(ValDef(Modifiers(LAZY), TermName("x"), TypeTree(), Apply(Ident(ListModule), List(Literal(Constant(1)), Literal(Constant(2)))))), Ident(TermName("x")))
toolBox.eval(Apply(reify, List(reifee)))
- val Block(List(tpeCopypaste), exprCopypaste @ ModuleDef(_, _, Template(_, _, (_ :: stats) :+ expr))) = toolBox.parse(output.toString())
+ val Block(List(tpeCopypaste, exprCopypaste @ ModuleDef(_, _, Template(_, _, (_ :: stats) :+ expr))), Literal(Constant(()))) = toolBox.parse(output.toString())
output.reset()
toolBox.eval(Block(stats, expr))
stdout.println(output.toString)
diff --git a/test/files/scalacheck/quasiquotes/DeprecationProps.scala b/test/files/scalacheck/quasiquotes/DeprecationProps.scala
new file mode 100644
index 0000000000..8e1601cf9d
--- /dev/null
+++ b/test/files/scalacheck/quasiquotes/DeprecationProps.scala
@@ -0,0 +1,52 @@
+import org.scalacheck._, Prop._, Gen._, Arbitrary._
+import scala.reflect.runtime.universe._
+
+object DeprecationProps extends QuasiquoteProperties("deprecation") {
+ val tname = TypeName("Foo")
+ val tpt = tq"Foo"
+ val tpe = typeOf[Int]
+ val sym = tpe.typeSymbol.asType
+ val argss = List(q"x") :: List(q"y") :: Nil
+ val args = q"x" :: q"y" :: Nil
+
+ property("new tpt argss") = test {
+ assert(q"new $tpt(...$argss)" ≈ New(tpt, argss))
+ }
+
+ property("new tpe args") = test {
+ assert(q"new $tpe(..$args)" ≈ New(tpe, args: _*))
+ }
+
+ property("new tpe args") = test {
+ assert(q"new ${sym.toType}(..$args)" ≈ New(sym, args: _*))
+ }
+
+ property("apply sym args") = test {
+ assert(q"$sym(..$args)" ≈ Apply(sym, args: _*))
+ }
+
+ property("applyconstructor") = test {
+ assert(q"new $tpt(..$args)" ≈ ApplyConstructor(tpt, args))
+ }
+
+ property("super sym name") = test {
+ assert(q"$sym.super[$tname].x".qualifier ≈ Super(sym, tname))
+ }
+
+ property("throw tpe args") = test {
+ assert(q"throw new $tpe(..$args)" ≈ Throw(tpe, args: _*))
+ }
+
+ property("casedef pat body") = test {
+ val pat = pq"foo"
+ val body = q"bar"
+ assert(cq"$pat => $body" ≈ CaseDef(pat, body))
+ }
+
+ property("try body cases") = test {
+ val cases = (pq"a", q"b") :: (pq"c", q"d") :: Nil
+ val newcases = cases.map { case (pat, body) => cq"$pat => $body" }
+ val body = q"foo"
+ assert(q"try $body catch { case ..$newcases }" ≈ Try(body, cases: _*))
+ }
+} \ No newline at end of file
diff --git a/test/files/scalacheck/quasiquotes/Test.scala b/test/files/scalacheck/quasiquotes/Test.scala
index 05097711ef..f41d961888 100644
--- a/test/files/scalacheck/quasiquotes/Test.scala
+++ b/test/files/scalacheck/quasiquotes/Test.scala
@@ -11,4 +11,5 @@ object Test extends Properties("quasiquotes") {
include(ErrorProps)
include(DefinitionConstructionProps)
include(DefinitionDeconstructionProps)
-} \ No newline at end of file
+ include(DeprecationProps)
+}