diff options
author | aleksandar <aleksandar@lampmac14.epfl.ch> | 2012-01-12 15:38:55 +0100 |
---|---|---|
committer | aleksandar <aleksandar@lampmac14.epfl.ch> | 2012-01-12 15:38:55 +0100 |
commit | 91fcdf64d406aed26d473091c3328c0cf089e115 (patch) | |
tree | e3897d0cc6b680d32581a740b16a4ad5ef0839ef /test/files/run | |
parent | 51ddeb372b3f0b22041d9a51f3faee17acd7b749 (diff) | |
parent | 5f5029d2ac6348ecb07fc11f6656621c662ced92 (diff) | |
download | scala-91fcdf64d406aed26d473091c3328c0cf089e115.tar.gz scala-91fcdf64d406aed26d473091c3328c0cf089e115.tar.bz2 scala-91fcdf64d406aed26d473091c3328c0cf089e115.zip |
Merge branch 'master' into issue/4147
Conflicts:
.gitignore
Diffstat (limited to 'test/files/run')
23 files changed, 236 insertions, 39 deletions
diff --git a/test/files/run/array-existential-bound.check b/test/files/run/array-existential-bound.check new file mode 100644 index 0000000000..f5cca843e3 --- /dev/null +++ b/test/files/run/array-existential-bound.check @@ -0,0 +1,4 @@ +2 +1000 +1000 +26 diff --git a/test/files/run/array-existential-bound.scala b/test/files/run/array-existential-bound.scala new file mode 100644 index 0000000000..bc442d39f7 --- /dev/null +++ b/test/files/run/array-existential-bound.scala @@ -0,0 +1,17 @@ +trait Fooz[Q <: Array[_]] { + def f0(x: Q) = x.length +} + +object Test extends Fooz[Array[Int]] { + val f1 = new Fooz[Array[String]] { } + val f2 = new Fooz[Array[Int]] { } + val f3 = new Fooz[Array[Any]] { } + val f4 = new Fooz[Array[_]] { } + + def main(args: Array[String]): Unit = { + println(f1.f0(Array[String]("a", "b"))) + println(f2.f0(1 to 1000 toArray)) + println(f3.f0((1 to 1000).toArray[Any])) + println(f4.f0('a' to 'z' toArray)) + } +} diff --git a/test/files/run/mixin-bridge-methods.scala b/test/files/run/mixin-bridge-methods.scala new file mode 100644 index 0000000000..e0340ebb12 --- /dev/null +++ b/test/files/run/mixin-bridge-methods.scala @@ -0,0 +1,14 @@ +trait Foo { + def getFoo() = "foo" +} + +class Sub extends Foo { + def getBar() = "bar" +} + +object Test { + def main(args: Array[String]): Unit = { + val ms = classOf[Sub].getDeclaredMethods + assert(ms forall (x => !x.isBridge), ms mkString " ") + } +} diff --git a/test/files/run/origins.scala b/test/files/run/origins.scala index ab873bca89..9dc6071c7b 100644 --- a/test/files/run/origins.scala +++ b/test/files/run/origins.scala @@ -1,4 +1,4 @@ -import scala.tools.nsc.util.Origins +import scala.reflect.internal.util.Origins package goxbox { object Socks { diff --git a/test/files/run/repl-power.check b/test/files/run/repl-power.check index 38e7532133..1e7b6f0cd8 100644 --- a/test/files/run/repl-power.check +++ b/test/files/run/repl-power.check @@ -2,15 +2,31 @@ Type in expressions to have them evaluated. Type :help for more information. scala> :power -** Power User mode enabled - BEEP BOOP SPIZ ** +** Power User mode enabled - BEEP WHIR GYVE ** ** :phase has been set to 'typer'. ** ** scala.tools.nsc._ has been imported ** -** global._ and definitions._ also imported ** -** Try :help, vals.<tab>, power.<tab> ** +** global._, definitions._ also imported ** +** Try :help, :vals, power.<tab> ** scala> // guarding against "error: reference to global is ambiguous" scala> global.emptyValDef // "it is imported twice in the same scope by ..." res0: $r.global.emptyValDef.type = private val _ = _ +scala> val tp = ArrayClass[scala.util.Random] // magic with manifests +tp: $r.global.Type = Array[scala.util.Random] + +scala> tp.memberType(Array_apply) // evidence +res1: $r.global.Type = (i: Int)scala.util.Random + +scala> val m = LIT(10) MATCH (CASE(LIT(5)) ==> FALSE, DEFAULT ==> TRUE) // treedsl +m: $r.treedsl.global.Match = +10 match { + case 5 => false + case _ => true +} + +scala> typed(m).tpe // typed is in scope +res2: $r.treedsl.global.Type = Boolean + scala> diff --git a/test/files/run/repl-power.scala b/test/files/run/repl-power.scala index 9f70ac4b68..27da3df106 100644 --- a/test/files/run/repl-power.scala +++ b/test/files/run/repl-power.scala @@ -5,6 +5,10 @@ object Test extends ReplTest { :power // guarding against "error: reference to global is ambiguous" global.emptyValDef // "it is imported twice in the same scope by ..." +val tp = ArrayClass[scala.util.Random] // magic with manifests +tp.memberType(Array_apply) // evidence +val m = LIT(10) MATCH (CASE(LIT(5)) ==> FALSE, DEFAULT ==> TRUE) // treedsl +typed(m).tpe // typed is in scope """.trim } diff --git a/test/files/run/t3758.scala b/test/files/run/t3758.scala new file mode 100644 index 0000000000..18750b0a9c --- /dev/null +++ b/test/files/run/t3758.scala @@ -0,0 +1,10 @@ +object Test { + def main(args: Array[String]): Unit = { + assert(classManifest[Array[String]].typeArguments contains classManifest[String]) + assert(classManifest[Array[Int]].typeArguments contains classManifest[Int]) + assert(classManifest[Array[Float]].typeArguments contains classManifest[Float]) + assert(manifest[Array[String]].typeArguments contains manifest[String]) + assert(manifest[Array[Int]].typeArguments contains manifest[Int]) + assert(manifest[Array[Float]].typeArguments contains manifest[Float]) + } +} diff --git a/test/files/run/t5239.check b/test/files/run/t5239.check deleted file mode 100644 index 40fe6a76e7..0000000000 --- a/test/files/run/t5239.check +++ /dev/null @@ -1,13 +0,0 @@ -result = 2{Int(2)} -[[syntax trees at end of typer]]// Scala source: NoSourceFile -package <empty> { - final object __wrapper$1 extends Object { - def this(): object __wrapper$1 = { - __wrapper$1.super.this(); - () - }; - def wrapper(): Int = 2 - } -} - -evaluated = 2 diff --git a/test/files/run/t5239.scala b/test/files/run/t5239.scala deleted file mode 100644 index 1f404196ba..0000000000 --- a/test/files/run/t5239.scala +++ /dev/null @@ -1,20 +0,0 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox - -object Test extends App { - val code = scala.reflect.Code.lift{ - 2 - }; - - val settings = new Settings - settings.Xprint.value = List("typer") - - val reporter = new ConsoleReporter(settings) - val toolbox = new ToolBox(reporter) - val ttree = toolbox.typeCheck(code.tree) - println("result = " + toolbox.showAttributed(ttree)) - - val evaluated = toolbox.runExpr(ttree) - println("evaluated = " + evaluated) -} diff --git a/test/files/run/t5300.scala b/test/files/run/t5300.scala new file mode 100644 index 0000000000..073b29604a --- /dev/null +++ b/test/files/run/t5300.scala @@ -0,0 +1,7 @@ +object Test { + val pf: PartialFunction[Any, Unit] = { case _ => () } + + def main(args: Array[String]): Unit = { + pf orElse pf + } +} diff --git a/test/files/run/t5356.check b/test/files/run/t5356.check new file mode 100644 index 0000000000..21c4aef07b --- /dev/null +++ b/test/files/run/t5356.check @@ -0,0 +1,6 @@ +1 scala.runtime.RichInt +1 scala.runtime.RichInt +1 scala.math.BigInt +1 scala.runtime.RichDouble +1 scala.runtime.RichFloat +1 diff --git a/test/files/run/t5356.scala b/test/files/run/t5356.scala new file mode 100644 index 0000000000..f7696c6088 --- /dev/null +++ b/test/files/run/t5356.scala @@ -0,0 +1,12 @@ +object Test { + def f(x: { def toInt: Int }) = println(x.toInt + " " + x.getClass.getName) + + def main(args: Array[String]): Unit = { + f(1) + f(1.toInt) + f(BigInt(1)) + f(1d) + f(1f) + println((1: { def toInt: Int }).toInt) + } +} diff --git a/test/files/run/treePrint.scala b/test/files/run/treePrint.scala index 745c2150c2..e0332a705f 100644 --- a/test/files/run/treePrint.scala +++ b/test/files/run/treePrint.scala @@ -35,7 +35,7 @@ object Test { settings.Ycompacttrees.value = true val intp = new IMain(settings, new PrintWriter(new NullOutputStream)) - val power = Power(intp) + val power = new Power(intp, new ReplVals { }) intp.interpret("""def initialize = "Have to interpret something or we get errors." """) power trees code foreach println } diff --git a/test/files/run/type-currying.check b/test/files/run/type-currying.check new file mode 100644 index 0000000000..e5db238ca5 --- /dev/null +++ b/test/files/run/type-currying.check @@ -0,0 +1,27 @@ +Map(abc -> 55) +(a,0) +(b,1) +(c,2) +(d,3) +(e,4) +(f,5) +(g,6) +(h,7) +(i,8) +(j,9) +(k,10) +(l,11) +(m,12) +(n,13) +(o,14) +(p,15) +(q,16) +(r,17) +(s,18) +(t,19) +(u,20) +(v,21) +(w,22) +(x,23) +(y,24) +(z,25) diff --git a/test/files/run/type-currying.scala b/test/files/run/type-currying.scala new file mode 100644 index 0000000000..f9764c64f0 --- /dev/null +++ b/test/files/run/type-currying.scala @@ -0,0 +1,58 @@ +import scala.collection.{ mutable, immutable, generic } +import generic.CanBuildFrom + +object Partial { + type KnownContainer[CC[K, V] <: collection.Map[K, V]] = { + def values[V] : KnownValues[CC, V] + def apply[K] : KnownKeys[CC, K] + } + type KnownKeys[CC[K, V] <: collection.Map[K, V], K] = { + def apply[V](implicit cbf: CanBuildFrom[_, (K, V), CC[K, V]]): CC[K, V] + } + type KnownValues[CC[K, V] <: collection.Map[K, V], V] = { + def apply[K](implicit cbf: CanBuildFrom[_, (K, V), CC[K, V]]): CC[K, V] + } + + def apply[CC[K, V] <: collection.Map[K, V]] : KnownContainer[CC] = new { + def values[V] : KnownValues[CC, V] = new { + def apply[K](implicit cbf: CanBuildFrom[_, (K, V), CC[K, V]]) = cbf().result + } + def apply[K] = new { + def apply[V](implicit cbf: CanBuildFrom[_, (K, V), CC[K, V]]) = cbf().result + } + } +} + +object Test { + val m = Partial[immutable.TreeMap] + val m1 = m[String] + val m2 = m[Int][Int] + + val mutableBippy = Partial[mutable.HashMap][String][Int] + mutableBippy("abc") = 55 + + val immutableBippy = Partial[immutable.HashMap].values[Int] + def make[T](xs: T*) = immutableBippy[T] ++ xs.zipWithIndex + + val n0 = Partial[immutable.HashMap][String][Int] ++ Seq(("a", 1)) + val n1 = Partial.apply[immutable.HashMap].apply[String].apply[Int] ++ Seq(("a", 1)) + + def main(args: Array[String]): Unit = { + println(mutableBippy) + make('a' to 'z': _*).toList.sorted foreach println + assert(n0 == n1) + } +} + +class A { + object Foo { + def apply[T] = Bar + } + object Bar { + def apply() = Foo + } + + def f() = Foo + def g = f()[Int]()[String]() + def h = Foo[Foo.type]()[Foo.type]() +} diff --git a/test/files/run/virtpatmat_literal.scala b/test/files/run/virtpatmat_literal.scala index cb72b1d2a5..5bd6b30791 100644 --- a/test/files/run/virtpatmat_literal.scala +++ b/test/files/run/virtpatmat_literal.scala @@ -1,8 +1,9 @@ object Test extends App { + val a = 1 1 match { case 2 => println("FAILED") case 1 => println("OK") - case 1 => println("FAILED") + case `a` => println("FAILED") } val one = 1 diff --git a/test/files/run/virtpatmat_opt_sharing.check b/test/files/run/virtpatmat_opt_sharing.check new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/test/files/run/virtpatmat_opt_sharing.check @@ -0,0 +1 @@ +1 diff --git a/test/files/run/virtpatmat_opt_sharing.flags b/test/files/run/virtpatmat_opt_sharing.flags new file mode 100644 index 0000000000..9769db9257 --- /dev/null +++ b/test/files/run/virtpatmat_opt_sharing.flags @@ -0,0 +1 @@ + -Yvirtpatmat -Xexperimental diff --git a/test/files/run/virtpatmat_opt_sharing.scala b/test/files/run/virtpatmat_opt_sharing.scala new file mode 100644 index 0000000000..119e3050ea --- /dev/null +++ b/test/files/run/virtpatmat_opt_sharing.scala @@ -0,0 +1,10 @@ +object Test extends App { + virtMatch() + def virtMatch() = { + List(1, 3, 4, 7) match { + case 1 :: 3 :: 4 :: 5 :: x => println("nope") + case 1 :: 3 :: 4 :: 6 :: x => println("nope") + case 1 :: 3 :: 4 :: 7 :: x => println(1) + } + } +}
\ No newline at end of file diff --git a/test/files/run/virtpatmat_unapplyprod.check b/test/files/run/virtpatmat_unapplyprod.check new file mode 100644 index 0000000000..2660ff8f96 --- /dev/null +++ b/test/files/run/virtpatmat_unapplyprod.check @@ -0,0 +1,4 @@ +(2,3) +(2,3) +(2,3) +List(true, false, true) diff --git a/test/files/run/virtpatmat_unapplyprod.flags b/test/files/run/virtpatmat_unapplyprod.flags new file mode 100644 index 0000000000..9769db9257 --- /dev/null +++ b/test/files/run/virtpatmat_unapplyprod.flags @@ -0,0 +1 @@ + -Yvirtpatmat -Xexperimental diff --git a/test/files/run/virtpatmat_unapplyprod.scala b/test/files/run/virtpatmat_unapplyprod.scala new file mode 100644 index 0000000000..441e5e3968 --- /dev/null +++ b/test/files/run/virtpatmat_unapplyprod.scala @@ -0,0 +1,23 @@ +object Test extends App { + case class Foo(x: Int, y: String) + + Foo(2, "3") match { + case Foo(x, y) => println((x, y)) + } + + case class FooSeq(x: Int, y: String, z: Boolean*) + + FooSeq(2, "3") match { + case FooSeq(x, y) => println((x, y)) + } + + FooSeq(2, "3", true, false, true) match { + case FooSeq(x, y) => println("nope") + case FooSeq(x, y, true, false, true) => println((x, y)) + } + + FooSeq(1, "a", true, false, true) match { + case FooSeq(1, "a") => println("nope") + case FooSeq(1, "a", x@_* ) => println(x.toList) + } +}
\ No newline at end of file diff --git a/test/files/run/xml-attribute.scala b/test/files/run/xml-attribute.scala new file mode 100644 index 0000000000..2b83f70b22 --- /dev/null +++ b/test/files/run/xml-attribute.scala @@ -0,0 +1,14 @@ +import xml.Node + +object Test { + def main(args: Array[String]): Unit = { + val noAttr = <t/> + val attrNull = <t a={ null: String }/> + val attrNone = <t a={ None: Option[Seq[Node]] }/> + assert(noAttr == attrNull) + assert(noAttr == attrNone) + assert(noAttr.toString() == "<t></t>") + assert(attrNull.toString() == "<t></t>") + assert(attrNone.toString() == "<t></t>") + } +} |