diff options
author | Paolo G. Giarrusso <p.giarrusso@gmail.com> | 2013-01-21 23:43:03 +0100 |
---|---|---|
committer | Paolo G. Giarrusso <p.giarrusso@gmail.com> | 2013-03-15 01:32:47 +0100 |
commit | 4bb8988e0263206fc914537c7762b0ee3b9057aa (patch) | |
tree | 862e6067aa76d6e87a9e683d550b74b817b6349a | |
parent | ec6548fb91309b72bd46ff939f79bb253ca5953a (diff) | |
download | scala-4bb8988e0263206fc914537c7762b0ee3b9057aa.tar.gz scala-4bb8988e0263206fc914537c7762b0ee3b9057aa.tar.bz2 scala-4bb8988e0263206fc914537c7762b0ee3b9057aa.zip |
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.
-rw-r--r-- | test/files/neg/abstract-explaintypes.check | 11 | ||||
-rw-r--r-- | test/files/neg/abstract-explaintypes.flags | 1 | ||||
-rw-r--r-- | test/files/neg/abstract-explaintypes.scala | 11 | ||||
-rw-r--r-- | test/files/pos/t6123-explaintypes-implicits.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t6123-explaintypes-implicits.scala | 13 | ||||
-rw-r--r-- | test/files/pos/t6123-explaintypes-macros.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t6123-explaintypes-macros.scala | 7 |
7 files changed, 45 insertions, 0 deletions
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] = ??? +} |