From 4bb8988e0263206fc914537c7762b0ee3b9057aa Mon Sep 17 00:00:00 2001 From: "Paolo G. Giarrusso" Date: Mon, 21 Jan 2013 23:43:03 +0100 Subject: Add positive and negative testcases for SI-6123 (-explaintypes) Positive testcases compile reduced known offenders to verify that no output is produced. The negative testcase tests that -explaintypes actually produces output on code which fails to compile. I have altered an existing testcase, `test/files/neg/abstract`, adding -explaintypes to the flags. This testcase is currently mostly ineffective, as partest currently ignores the standard output (SI-7003). It will become more effective when SI-7003 is fixed. But already now, testers would at least be able to notice extraneous output. This argument is somewhat bogus, but this patch is no worse than the other ones which are committed while SI-7003 is open. --- test/files/neg/abstract-explaintypes.check | 11 +++++++++++ test/files/neg/abstract-explaintypes.flags | 1 + test/files/neg/abstract-explaintypes.scala | 11 +++++++++++ test/files/pos/t6123-explaintypes-implicits.flags | 1 + test/files/pos/t6123-explaintypes-implicits.scala | 13 +++++++++++++ test/files/pos/t6123-explaintypes-macros.flags | 1 + test/files/pos/t6123-explaintypes-macros.scala | 7 +++++++ 7 files changed, 45 insertions(+) create mode 100644 test/files/neg/abstract-explaintypes.check create mode 100644 test/files/neg/abstract-explaintypes.flags create mode 100644 test/files/neg/abstract-explaintypes.scala create mode 100644 test/files/pos/t6123-explaintypes-implicits.flags create mode 100644 test/files/pos/t6123-explaintypes-implicits.scala create mode 100644 test/files/pos/t6123-explaintypes-macros.flags create mode 100644 test/files/pos/t6123-explaintypes-macros.scala (limited to 'test/files') diff --git a/test/files/neg/abstract-explaintypes.check b/test/files/neg/abstract-explaintypes.check new file mode 100644 index 0000000000..59c1ad2378 --- /dev/null +++ b/test/files/neg/abstract-explaintypes.check @@ -0,0 +1,11 @@ +abstract-explaintypes.scala:6: error: type mismatch; + found : A + required: A.this.T + def foo2: T = bar().baz(); + ^ +abstract-explaintypes.scala:9: error: type mismatch; + found : A + required: A.this.T + def foo5: T = baz().baz(); + ^ +two errors found diff --git a/test/files/neg/abstract-explaintypes.flags b/test/files/neg/abstract-explaintypes.flags new file mode 100644 index 0000000000..b36707c7cf --- /dev/null +++ b/test/files/neg/abstract-explaintypes.flags @@ -0,0 +1 @@ +-explaintypes diff --git a/test/files/neg/abstract-explaintypes.scala b/test/files/neg/abstract-explaintypes.scala new file mode 100644 index 0000000000..f8ecae16fa --- /dev/null +++ b/test/files/neg/abstract-explaintypes.scala @@ -0,0 +1,11 @@ +trait A { + type T <: A; + def baz(): A; + def bar(): T; + def foo1: A = bar().bar(); + def foo2: T = bar().baz(); + def foo3 = bar().baz(); + def foo4: A = baz().bar(); + def foo5: T = baz().baz(); + def foo6 = baz().baz(); +} diff --git a/test/files/pos/t6123-explaintypes-implicits.flags b/test/files/pos/t6123-explaintypes-implicits.flags new file mode 100644 index 0000000000..b36707c7cf --- /dev/null +++ b/test/files/pos/t6123-explaintypes-implicits.flags @@ -0,0 +1 @@ +-explaintypes diff --git a/test/files/pos/t6123-explaintypes-implicits.scala b/test/files/pos/t6123-explaintypes-implicits.scala new file mode 100644 index 0000000000..5242b443d5 --- /dev/null +++ b/test/files/pos/t6123-explaintypes-implicits.scala @@ -0,0 +1,13 @@ +object ImplicitBugReport { + trait Exp[+T] + trait CanBuildExp[-Elem, +To] extends (Exp[Elem] => To) + trait TraversableExp[T, ExpT <: Exp[T]] extends Exp[Traversable[T]] + + implicit def canBuildExp[T]: CanBuildExp[T, Exp[T]] = ??? + implicit def canBuildExpTrav[T, ExpT <: Exp[T]](implicit c: CanBuildExp[T, ExpT]): CanBuildExp[Traversable[T], TraversableExp[T, ExpT]] = ??? + def toExpTempl[T, That](t: T)(implicit c: CanBuildExp[T, That]): That = ??? + + def testBug() { + val a1 = toExpTempl(Seq(1, 2, 3, 5)) + } +} diff --git a/test/files/pos/t6123-explaintypes-macros.flags b/test/files/pos/t6123-explaintypes-macros.flags new file mode 100644 index 0000000000..b36707c7cf --- /dev/null +++ b/test/files/pos/t6123-explaintypes-macros.flags @@ -0,0 +1 @@ +-explaintypes diff --git a/test/files/pos/t6123-explaintypes-macros.scala b/test/files/pos/t6123-explaintypes-macros.scala new file mode 100644 index 0000000000..e650ad2038 --- /dev/null +++ b/test/files/pos/t6123-explaintypes-macros.scala @@ -0,0 +1,7 @@ +import scala.language.experimental.macros +import scala.reflect.macros.Context + +object Macros { + def printf(format: String, params: Any*): Unit = macro printf_impl + def printf_impl(c: Context)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit] = ??? +} -- cgit v1.2.3