diff options
author | Roland <rk@rkuhn.info> | 2012-09-12 14:28:39 +0200 |
---|---|---|
committer | Roland <rk@rkuhn.info> | 2012-09-12 14:28:39 +0200 |
commit | 13ff968b9d273e03bfa226ca1ec52949391a6b68 (patch) | |
tree | 51e64bff6fb38fa212b7e187ee4f0a02be1e3e23 /test/files | |
parent | 300803606ebca352955e945cf468a0c2bfc83b9c (diff) | |
parent | d9a4e94f8716b810e8122c6494b1718410238668 (diff) | |
download | scala-13ff968b9d273e03bfa226ca1ec52949391a6b68.tar.gz scala-13ff968b9d273e03bfa226ca1ec52949391a6b68.tar.bz2 scala-13ff968b9d273e03bfa226ca1ec52949391a6b68.zip |
Merge remote-tracking branch 'origin/2.10.x' into fix-duration-issues-RK
Diffstat (limited to 'test/files')
54 files changed, 665 insertions, 80 deletions
diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala index ffb5608fd2..0e76b711de 100644 --- a/test/files/jvm/scala-concurrent-tck.scala +++ b/test/files/jvm/scala-concurrent-tck.scala @@ -11,6 +11,8 @@ import scala.concurrent.{ import scala.concurrent.{ future, promise, blocking } import scala.util.{ Try, Success, Failure } import scala.concurrent.util.Duration +import scala.reflect.{ classTag, ClassTag } +import scala.tools.partest.TestUtil.intercept trait TestBase { @@ -19,7 +21,7 @@ trait TestBase { body(() => sv put true) sv.take(2000) } - + // def assert(cond: => Boolean) { // try { // Predef.assert(cond) @@ -663,6 +665,29 @@ trait FutureProjections extends TestBase { case nsee: NoSuchElementException => done() } } + + def testAwaitPositiveDuration(): Unit = once { done => + val p = Promise[Int]() + val f = p.future + future { + intercept[IllegalArgumentException] { Await.ready(f, Duration.Undefined) } + p.success(0) + Await.ready(f, Duration.Zero) + Await.ready(f, Duration(500, "ms")) + Await.ready(f, Duration.Inf) + done() + } onFailure { case x => throw x } + } + + def testAwaitNegativeDuration(): Unit = once { done => + val f = Promise().future + future { + intercept[TimeoutException] { Await.ready(f, Duration.Zero) } + intercept[TimeoutException] { Await.ready(f, Duration.MinusInf) } + intercept[TimeoutException] { Await.ready(f, Duration(-500, "ms")) } + done() + } onFailure { case x => throw x } + } testFailedFailureOnComplete() testFailedFailureOnSuccess() @@ -670,6 +695,8 @@ trait FutureProjections extends TestBase { testFailedSuccessOnFailure() testFailedFailureAwait() testFailedSuccessAwait() + testAwaitPositiveDuration() + testAwaitNegativeDuration() } diff --git a/test/files/neg/override.check b/test/files/neg/override.check index fc152cb3b1..8be98bf4d0 100644 --- a/test/files/neg/override.check +++ b/test/files/neg/override.check @@ -1,5 +1,5 @@ override.scala:9: error: overriding type T in trait A with bounds >: Int <: Int; type T in trait B with bounds >: String <: String has incompatible type - lazy val x : A with B = x + lazy val x : A with B = {println(""); x} ^ one error found diff --git a/test/files/neg/override.scala b/test/files/neg/override.scala index 3e589b52e3..7975516061 100755 --- a/test/files/neg/override.scala +++ b/test/files/neg/override.scala @@ -6,7 +6,7 @@ trait X { trait Y extends X { trait B { type T >: String <: String } - lazy val x : A with B = x + lazy val x : A with B = {println(""); x} n = "foo" } diff --git a/test/files/neg/t5031.check b/test/files/neg/t5031.check index 8983d8daf9..2f1090c321 100644 --- a/test/files/neg/t5031.check +++ b/test/files/neg/t5031.check @@ -1,5 +1,5 @@ -Id.scala:3: error: Companions 'class Test' and 'object Test' must be defined in same file: +package.scala:2: error: Companions 'class Test' and 'object Test' must be defined in same file: Found in t5031/package.scala and t5031/Id.scala -object Test - ^ + class Test + ^ one error found diff --git a/test/files/neg/t5031b.check b/test/files/neg/t5031b.check new file mode 100644 index 0000000000..3bc2284a4d --- /dev/null +++ b/test/files/neg/t5031b.check @@ -0,0 +1,5 @@ +b.scala:3: error: Companions 'class Bippy' and 'object Bippy' must be defined in same file: + Found in t5031b/a.scala and t5031b/b.scala +object Bippy + ^ +one error found diff --git a/test/files/neg/t5031b/a.scala b/test/files/neg/t5031b/a.scala new file mode 100644 index 0000000000..0ab9aa9769 --- /dev/null +++ b/test/files/neg/t5031b/a.scala @@ -0,0 +1,3 @@ +package foo + +class Bippy diff --git a/test/files/neg/t5031b/b.scala b/test/files/neg/t5031b/b.scala new file mode 100644 index 0000000000..bdef237af5 --- /dev/null +++ b/test/files/neg/t5031b/b.scala @@ -0,0 +1,3 @@ +package foo + +object Bippy diff --git a/test/files/neg/t6162-inheritance.check b/test/files/neg/t6162-inheritance.check new file mode 100644 index 0000000000..a7d3cc3238 --- /dev/null +++ b/test/files/neg/t6162-inheritance.check @@ -0,0 +1,10 @@ +t6162-inheritance.scala:6: error: inheritance from class Foo in package t6126 is deprecated: `Foo` will be made final in a future version. +class SubFoo extends Foo + ^ +t6162-inheritance.scala:11: error: inheritance from trait T in package t6126 is deprecated +object SubT extends T + ^ +t6162-inheritance.scala:17: error: inheritance from trait S in package t6126 is deprecated + new S { + ^ +three errors found diff --git a/test/files/neg/t6162-inheritance.flags b/test/files/neg/t6162-inheritance.flags new file mode 100644 index 0000000000..65faf53579 --- /dev/null +++ b/test/files/neg/t6162-inheritance.flags @@ -0,0 +1 @@ +-Xfatal-warnings -deprecation
\ No newline at end of file diff --git a/test/files/neg/t6162-inheritance.scala b/test/files/neg/t6162-inheritance.scala new file mode 100644 index 0000000000..7b47b9285a --- /dev/null +++ b/test/files/neg/t6162-inheritance.scala @@ -0,0 +1,19 @@ +package scala.t6126 + +@deprecatedInheritance("`Foo` will be made final in a future version.", "2.10.0") +class Foo + +class SubFoo extends Foo + +@deprecatedInheritance() +trait T + +object SubT extends T + +@deprecatedInheritance() +trait S + +object O { + new S { + } +} diff --git a/test/files/neg/t6162-overriding.check b/test/files/neg/t6162-overriding.check new file mode 100644 index 0000000000..e774888d36 --- /dev/null +++ b/test/files/neg/t6162-overriding.check @@ -0,0 +1,7 @@ +t6162-overriding.scala:14: error: overriding method bar in class Bar is deprecated: `bar` will be made private in a future version. + override def bar = 43 + ^ +t6162-overriding.scala:15: error: overriding method baz in class Bar is deprecated + override def baz = 43 + ^ +two errors found diff --git a/test/files/neg/t6162-overriding.flags b/test/files/neg/t6162-overriding.flags new file mode 100644 index 0000000000..65faf53579 --- /dev/null +++ b/test/files/neg/t6162-overriding.flags @@ -0,0 +1 @@ +-Xfatal-warnings -deprecation
\ No newline at end of file diff --git a/test/files/neg/t6162-overriding.scala b/test/files/neg/t6162-overriding.scala new file mode 100644 index 0000000000..4cab0c2dee --- /dev/null +++ b/test/files/neg/t6162-overriding.scala @@ -0,0 +1,17 @@ +package scala.t6162 + +class Bar { + @deprecatedOverriding("`bar` will be made private in a future version.", "2.10.0") + def bar = 42 + + @deprecatedOverriding() + def baz = 42 + + def baz(a: Any) = 0 +} + +class SubBar extends Bar { + override def bar = 43 + override def baz = 43 + override def baz(a: Any) = 43 // okay +} diff --git a/test/files/neg/t6258.check b/test/files/neg/t6258.check new file mode 100644 index 0000000000..73363d8280 --- /dev/null +++ b/test/files/neg/t6258.check @@ -0,0 +1,16 @@ +t6258.scala:2: error: missing parameter type for expanded function +The argument types of an anonymous function must be fully known. (SLS 8.5) +Expected type was: PartialFunction[?, Int] + val f : PartialFunction[_, Int] = { case a : Int => a } // undefined param + ^ +t6258.scala:5: error: missing parameter type for expanded function +The argument types of an anonymous function must be fully known. (SLS 8.5) +Expected type was: PartialFunction[?,Int] + foo { case a : Int => a } // undefined param + ^ +t6258.scala:22: error: missing parameter type for expanded function +The argument types of an anonymous function must be fully known. (SLS 8.5) +Expected type was: PartialFunction[?,Any] + bar[M[Any]] (foo { // undefined param + ^ +three errors found diff --git a/test/files/neg/t6258.scala b/test/files/neg/t6258.scala new file mode 100644 index 0000000000..5046a4750a --- /dev/null +++ b/test/files/neg/t6258.scala @@ -0,0 +1,25 @@ +object Test { + val f : PartialFunction[_, Int] = { case a : Int => a } // undefined param + + def foo[A](pf: PartialFunction[A, Int]) {}; + foo { case a : Int => a } // undefined param + + val g : PartialFunction[Int, _] = { case a : Int => a } // okay +} + + +// Another variation, seen in the wild with Specs2. +class X { + trait Matcher[-T] + + def bar[T](m: Matcher[T]) = null + def bar[T](i: Int) = null + + def foo[T](p: PartialFunction[T, Any]): Matcher[T] = null + + case class M[X](a: X) + + bar[M[Any]] (foo { // undefined param + case M(_) => null + }) +} diff --git a/test/files/neg/t6276.check b/test/files/neg/t6276.check new file mode 100644 index 0000000000..0b3dfa5531 --- /dev/null +++ b/test/files/neg/t6276.check @@ -0,0 +1,19 @@ +t6276.scala:4: error: method a in class C does nothing other than call itself recursively + def a: Any = a // warn + ^ +t6276.scala:5: error: value b in class C does nothing other than call itself recursively + val b: Any = b // warn + ^ +t6276.scala:7: error: method c in class C does nothing other than call itself recursively + def c: Any = this.c // warn + ^ +t6276.scala:8: error: method d in class C does nothing other than call itself recursively + def d: Any = C.this.d // warn + ^ +t6276.scala:13: error: method a does nothing other than call itself recursively + def a: Any = a // warn + ^ +t6276.scala:22: error: method a does nothing other than call itself recursively + def a = a // warn + ^ +6 errors found diff --git a/test/files/neg/t6276.flags b/test/files/neg/t6276.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t6276.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t6276.scala b/test/files/neg/t6276.scala new file mode 100644 index 0000000000..bd0a473f71 --- /dev/null +++ b/test/files/neg/t6276.scala @@ -0,0 +1,44 @@ +object Test { + def foo(a: Int, b: Int, c: Int) { + class C { + def a: Any = a // warn + val b: Any = b // warn + + def c: Any = this.c // warn + def d: Any = C.this.d // warn + } + + def method { + // method local + def a: Any = a // warn + } + + trait T { + def a: Any + } + + new T { + // inherited return type + def a = a // warn + } + + // no warnings below + new { + def a: Any = {println(""); a} + val b: Any = {println(""); b} + def c(i: Int): Any = c(i - 0) + } + + class D { + def other: D = null + def foo: Any = other.foo + } + + class E { + def foo: Any = 0 + class D extends E { + override def foo: Any = E.this.foo + } + } + } +} diff --git a/test/files/neg/t6335.check b/test/files/neg/t6335.check new file mode 100644 index 0000000000..1727a05eb2 --- /dev/null +++ b/test/files/neg/t6335.check @@ -0,0 +1,9 @@ +t6335.scala:6: error: method Z is defined twice + conflicting symbols both originated in file 't6335.scala' + implicit class Z[A](val i: A) { def zz = i } + ^ +t6335.scala:3: error: method X is defined twice + conflicting symbols both originated in file 't6335.scala' + implicit class X(val x: Int) { def xx = x } + ^ +two errors found diff --git a/test/files/neg/t6335.scala b/test/files/neg/t6335.scala new file mode 100644 index 0000000000..5c41e81ef5 --- /dev/null +++ b/test/files/neg/t6335.scala @@ -0,0 +1,7 @@ +object ImplicitClass { + def X(i: Int) {} + implicit class X(val x: Int) { def xx = x } + + def Z[A](i: A) {} + implicit class Z[A](val i: A) { def zz = i } +}
\ No newline at end of file diff --git a/test/files/pos/t2868.cmds b/test/files/pos/t2868.cmds deleted file mode 100644 index ed8124a9e0..0000000000 --- a/test/files/pos/t2868.cmds +++ /dev/null @@ -1,3 +0,0 @@ -javac Jann.java Nest.java -scalac pick_1.scala -scalac test_2.scala diff --git a/test/files/pos/t2868/Jann.java b/test/files/pos/t2868/Jann.java deleted file mode 100644 index f5b68de7b0..0000000000 --- a/test/files/pos/t2868/Jann.java +++ /dev/null @@ -1,5 +0,0 @@ -public @interface Jann { - public String str(); - public Nest inn(); - public int[] arr(); -} diff --git a/test/files/pos/t2868/Nest.java b/test/files/pos/t2868/Nest.java deleted file mode 100644 index 53652291ad..0000000000 --- a/test/files/pos/t2868/Nest.java +++ /dev/null @@ -1,3 +0,0 @@ -public @interface Nest { - public int value(); -} diff --git a/test/files/pos/t2868/pick_1.scala b/test/files/pos/t2868/pick_1.scala deleted file mode 100644 index a211687432..0000000000 --- a/test/files/pos/t2868/pick_1.scala +++ /dev/null @@ -1,7 +0,0 @@ -class ann(s: String) extends annotation.StaticAnnotation -class pick { - final val s = "bang!" - @ann("bang!") def foo = 1 - @Jann(str = "bang!", inn = new Nest(1), arr = Array(1, 2)) def bar = 2 - @Jann(str = "bang!", inn = new Nest(1), arr = Array(1, 2)) def baz = 3 -} diff --git a/test/files/pos/t2868/t2868_src_2.scala b/test/files/pos/t2868/t2868_src_2.scala deleted file mode 100644 index f11ef0fae2..0000000000 --- a/test/files/pos/t2868/t2868_src_2.scala +++ /dev/null @@ -1,6 +0,0 @@ -class test { - val l = (new pick).s - val u = (new pick).foo - val c = (new pick).bar - val k = (new pick).baz -} diff --git a/test/files/pos/t6278-synth-def.scala b/test/files/pos/t6278-synth-def.scala new file mode 100644 index 0000000000..b8b660fbe3 --- /dev/null +++ b/test/files/pos/t6278-synth-def.scala @@ -0,0 +1,30 @@ + +package t6278 + +import language.implicitConversions + +object test { + def ok() { + class Foo(val i: Int) { + def foo[A](body: =>A): A = body + } + implicit def toFoo(i: Int): Foo = new Foo(i) + + val k = 1 + k foo println("k?") + val j = 2 + } + def nope() { + implicit class Foo(val i: Int) { + def foo[A](body: =>A): A = body + } + + val k = 1 + k foo println("k?") + //lazy + val j = 2 + } + def main(args: Array[String]) { + ok(); nope() + } +} diff --git a/test/files/pos/t6335.scala b/test/files/pos/t6335.scala new file mode 100644 index 0000000000..50e34092d1 --- /dev/null +++ b/test/files/pos/t6335.scala @@ -0,0 +1,25 @@ +object E extends Z { + def X = 3 + implicit class X(val i: Int) { + def xx = i + } + + def Y(a: Any) = 0 + object Y + implicit class Y(val i: String) { def yy = i } + + implicit class Z(val i: Boolean) { def zz = i } +} + +trait Z { + def Z = 0 +} + +object Test { + import E._ + 0.xx + + "".yy + + true.zz +} diff --git a/test/files/run/classtags_core.check b/test/files/run/classtags_core.check index 6519db2178..5a9b41fd6d 100644 --- a/test/files/run/classtags_core.check +++ b/test/files/run/classtags_core.check @@ -1,30 +1,30 @@ true
-ClassTag[byte]
+Byte
true
-ClassTag[short]
+Short
true
-ClassTag[char]
+Char
true
-ClassTag[int]
+Int
true
-ClassTag[long]
+Long
true
-ClassTag[float]
+Float
true
-ClassTag[double]
+Double
true
-ClassTag[boolean]
+Boolean
true
-ClassTag[void]
+Unit
true
-ClassTag[class java.lang.Object]
+Any
true
-ClassTag[class java.lang.Object]
+AnyVal
true
-ClassTag[class java.lang.Object]
+Object
true
-ClassTag[class java.lang.Object]
+Object
true
-ClassTag[class scala.runtime.Null$]
+Null
true
-ClassTag[class scala.runtime.Nothing$]
+Nothing
diff --git a/test/files/run/classtags_multi.check b/test/files/run/classtags_multi.check index 3a7f16c3a0..68cee4841d 100644 --- a/test/files/run/classtags_multi.check +++ b/test/files/run/classtags_multi.check @@ -1,5 +1,5 @@ -ClassTag[int]
-ClassTag[class [I]
-ClassTag[class [[I]
-ClassTag[class [[[I]
-ClassTag[class [[[[I]
+Int
+Array[int]
+Array[Array[int]]
+Array[Array[Array[int]]]
+Array[Array[Array[Array[int]]]]
diff --git a/test/files/run/compiler-asSeenFrom.check b/test/files/run/compiler-asSeenFrom.check index 96e257d303..47d40b0331 100644 --- a/test/files/run/compiler-asSeenFrom.check +++ b/test/files/run/compiler-asSeenFrom.check @@ -269,8 +269,8 @@ value jZ { // after parser value jZ { // after explicitouter protected val $outer: D.this.type - val ll$D$J$$$outer(): D.this.type - val ll$C$I$$$outer(): C.this.type + val $outer(): D.this.type + val $outer(): C.this.type def thisI(): I.this.type def thisC(): C.this.type def t2(): T2 @@ -279,9 +279,9 @@ value jZ { // after explicitouter value jZ { // after erasure protected val $outer: ll.D - val ll$D$J$$$outer(): ll.D + val $outer(): ll.D protected val $outer: ll.C - val ll$C$I$$$outer(): ll.C + val $outer(): ll.C def thisI(): ll.C#I def thisC(): ll.C def t2(): Object @@ -290,9 +290,9 @@ value jZ { // after erasure value jZ { // after flatten protected val $outer: ll.D - val ll$D$J$$$outer(): ll.D + val $outer(): ll.D protected val $outer: ll.C - val ll$C$I$$$outer(): ll.C + val $outer(): ll.C def thisI(): ll.C#C$I def thisC(): ll.C def t2(): Object diff --git a/test/files/run/getClassTest-valueClass.check b/test/files/run/getClassTest-valueClass.check new file mode 100644 index 0000000000..7608d92b4e --- /dev/null +++ b/test/files/run/getClassTest-valueClass.check @@ -0,0 +1,2 @@ +int +class V diff --git a/test/files/run/getClassTest-valueClass.scala b/test/files/run/getClassTest-valueClass.scala new file mode 100644 index 0000000000..05a116dfff --- /dev/null +++ b/test/files/run/getClassTest-valueClass.scala @@ -0,0 +1,10 @@ +class V(val x: Int) extends AnyVal + +object Test { + def main(args: Array[String]) = { + val v = new V(2) + val s: Any = 2 + println(2.getClass) + println(v.getClass) + } +} diff --git a/test/files/run/interop_classtags_are_classmanifests.check b/test/files/run/interop_classtags_are_classmanifests.check index 7a0a829af2..c07ed0e657 100644 --- a/test/files/run/interop_classtags_are_classmanifests.check +++ b/test/files/run/interop_classtags_are_classmanifests.check @@ -1,3 +1,3 @@ -ClassTag[int]
-ClassTag[class java.lang.String]
-ClassTag[class [I]
+Int
+java.lang.String
+Array[int]
diff --git a/test/files/run/macro-expand-tparams-implicit.check b/test/files/run/macro-expand-tparams-implicit.check index 80c6b826ba..1c1a785706 100644 --- a/test/files/run/macro-expand-tparams-implicit.check +++ b/test/files/run/macro-expand-tparams-implicit.check @@ -1,2 +1,2 @@ TypeTag[Int]
-TypeTag[String]
+AbsTypeTag[String]
diff --git a/test/files/run/macro-expand-tparams-prefix-a.check b/test/files/run/macro-expand-tparams-prefix-a.check index 6c23b47d64..6a7f9c5f52 100644 --- a/test/files/run/macro-expand-tparams-prefix-a.check +++ b/test/files/run/macro-expand-tparams-prefix-a.check @@ -1,4 +1,4 @@ TypeTag[Int]
TypeTag[Int]
-TypeTag[String]
+AbsTypeTag[String]
TypeTag[Boolean]
diff --git a/test/files/run/macro-expand-tparams-prefix-b.check b/test/files/run/macro-expand-tparams-prefix-b.check index 67dabff11e..daae32bd0a 100644 --- a/test/files/run/macro-expand-tparams-prefix-b.check +++ b/test/files/run/macro-expand-tparams-prefix-b.check @@ -1,2 +1,2 @@ TypeTag[Boolean] TypeTag[Int]
-TypeTag[Boolean] TypeTag[String]
+TypeTag[Boolean] AbsTypeTag[String]
diff --git a/test/files/run/macro-expand-tparams-prefix-c1.check b/test/files/run/macro-expand-tparams-prefix-c1.check index 8d1c4e3416..5356b3e6d1 100644 --- a/test/files/run/macro-expand-tparams-prefix-c1.check +++ b/test/files/run/macro-expand-tparams-prefix-c1.check @@ -1,3 +1,3 @@ TypeTag[Int]
-TypeTag[String]
+AbsTypeTag[String]
TypeTag[Boolean]
diff --git a/test/files/run/macro-expand-tparams-prefix-c2.check b/test/files/run/macro-expand-tparams-prefix-c2.check index 8d1c4e3416..5356b3e6d1 100644 --- a/test/files/run/macro-expand-tparams-prefix-c2.check +++ b/test/files/run/macro-expand-tparams-prefix-c2.check @@ -1,3 +1,3 @@ TypeTag[Int]
-TypeTag[String]
+AbsTypeTag[String]
TypeTag[Boolean]
diff --git a/test/files/run/macro-undetparams-macroitself.check b/test/files/run/macro-undetparams-macroitself.check index 80c6b826ba..1c1a785706 100644 --- a/test/files/run/macro-undetparams-macroitself.check +++ b/test/files/run/macro-undetparams-macroitself.check @@ -1,2 +1,2 @@ TypeTag[Int]
-TypeTag[String]
+AbsTypeTag[String]
diff --git a/test/files/run/t5881.check b/test/files/run/t5881.check index 477fb935a8..8e596e9323 100644 --- a/test/files/run/t5881.check +++ b/test/files/run/t5881.check @@ -1,2 +1,2 @@ -ClassTag[class scala.collection.immutable.List]
-ClassTag[class scala.collection.immutable.List]
+scala.collection.immutable.List
+scala.collection.immutable.List
diff --git a/test/files/run/t6246.check b/test/files/run/t6246.check new file mode 100644 index 0000000000..9532185ead --- /dev/null +++ b/test/files/run/t6246.check @@ -0,0 +1,90 @@ +runtimeClass = byte, toString = Byte +true +true +true +false +true +false +false +false +false +runtimeClass = short, toString = Short +true +true +true +false +true +false +false +false +false +runtimeClass = char, toString = Char +true +true +true +false +true +false +false +false +false +runtimeClass = int, toString = Int +true +true +true +false +true +false +false +false +false +runtimeClass = long, toString = Long +true +true +true +false +true +false +false +false +false +runtimeClass = float, toString = Float +true +true +true +false +true +false +false +false +false +runtimeClass = double, toString = Double +true +true +true +false +true +false +false +false +false +runtimeClass = void, toString = Unit +true +true +true +false +true +false +false +false +false +runtimeClass = boolean, toString = Boolean +true +true +true +false +true +false +false +false +false
\ No newline at end of file diff --git a/test/files/run/t6246.scala b/test/files/run/t6246.scala new file mode 100644 index 0000000000..28765e1adf --- /dev/null +++ b/test/files/run/t6246.scala @@ -0,0 +1,26 @@ +import scala.reflect.{ClassTag, classTag} + +object Test extends App { + def testValueClass(tag: ClassTag[_]) { + println(s"runtimeClass = ${tag.runtimeClass}, toString = ${tag.toString}") + println(tag <:< tag) + println(tag <:< ClassTag.AnyVal) + println(tag <:< ClassTag.Any) + println(tag <:< ClassTag.Nothing) + println(ClassTag.Nothing <:< tag) + println(tag <:< ClassTag.Null) + println(ClassTag.Null <:< tag) + println(tag <:< ClassTag.Object) + println(ClassTag.Object <:< tag) + } + + testValueClass(ClassTag.Byte) + testValueClass(ClassTag.Short) + testValueClass(ClassTag.Char) + testValueClass(ClassTag.Int) + testValueClass(ClassTag.Long) + testValueClass(ClassTag.Float) + testValueClass(ClassTag.Double) + testValueClass(ClassTag.Unit) + testValueClass(ClassTag.Boolean) +}
\ No newline at end of file diff --git a/test/files/run/t6271.scala b/test/files/run/t6271.scala new file mode 100644 index 0000000000..8ebf7ad8b5 --- /dev/null +++ b/test/files/run/t6271.scala @@ -0,0 +1,32 @@ +object Test extends App { + def filterIssue = { + val viewed : Iterable[Iterable[Int]] = List(List(0).view).view + val filtered = viewed flatMap { x => List( x filter (_ > 0) ) } + filtered.iterator.toIterable.flatten + } + def takenIssue = { + val viewed : Iterable[Iterable[Int]] = List(List(0).view).view + val filtered = viewed flatMap { x => List( x take 0 ) } + filtered.iterator.toIterable.flatten + } + def droppedIssue = { + val viewed : Iterable[Iterable[Int]] = List(List(0).view).view + val filtered = viewed flatMap { x => List( x drop 1 ) } + filtered.iterator.toIterable.flatten + } + def flatMappedIssue = { + val viewed : Iterable[Iterable[Int]] = List(List(0).view).view + val filtered = viewed flatMap { x => List( x flatMap (_ => List()) ) } + filtered.iterator.toIterable.flatten + } + def slicedIssue = { + val viewed : Iterable[Iterable[Int]] = List(List(0).view).view + val filtered = viewed flatMap { x => List( x slice (2,3) ) } + filtered.iterator.toIterable.flatten + } + filterIssue + takenIssue + droppedIssue + flatMappedIssue + slicedIssue +} diff --git a/test/files/run/t6318_derived.check b/test/files/run/t6318_derived.check new file mode 100644 index 0000000000..ad43b6579b --- /dev/null +++ b/test/files/run/t6318_derived.check @@ -0,0 +1,3 @@ +Some(X)
+true
+Some(X)
diff --git a/test/files/run/t6318_derived.scala b/test/files/run/t6318_derived.scala new file mode 100644 index 0000000000..ccdc18daee --- /dev/null +++ b/test/files/run/t6318_derived.scala @@ -0,0 +1,15 @@ +import scala.reflect.{ClassTag, classTag} + +object Test extends App { + def test[T: ClassTag](x: T) { + println(classTag[T].runtimeClass.isAssignableFrom(x.getClass)) + println(classTag[T].unapply(x)) + } + + class X(val x: Int) extends AnyVal { override def toString = "X" } + val x = new X(1) + // the commented line crashes because of SI-6326 + //println(classTag[X].runtimeClass.isAssignableFrom(x.getClass)) + println(classTag[X].unapply(x)) + test(x) +}
\ No newline at end of file diff --git a/test/files/run/t6318_primitives.check b/test/files/run/t6318_primitives.check new file mode 100644 index 0000000000..bb474c3bdc --- /dev/null +++ b/test/files/run/t6318_primitives.check @@ -0,0 +1,36 @@ +true
+Some(1)
+false
+None
+true
+Some(1)
+false
+None
+true
+Some()
+false
+None
+true
+Some(1)
+false
+None
+true
+Some(1)
+false
+None
+true
+Some(1.0)
+false
+None
+true
+Some(1.0)
+false
+None
+true
+Some(true)
+false
+None
+true
+Some(())
+false
+None
diff --git a/test/files/run/t6318_primitives.scala b/test/files/run/t6318_primitives.scala new file mode 100644 index 0000000000..30f27120b3 --- /dev/null +++ b/test/files/run/t6318_primitives.scala @@ -0,0 +1,71 @@ +import scala.reflect.{ClassTag, classTag} + +object Test extends App { + def test[T: ClassTag](x: T) { + println(classTag[T].runtimeClass.isAssignableFrom(x.getClass)) + println(classTag[T].unapply(x)) + } + + { + val x = 1.toByte + println(ClassTag.Byte.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Byte.unapply(x)) + test(x) + } + + { + val x = 1.toShort + println(ClassTag.Short.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Short.unapply(x)) + test(x) + } + + { + val x = 1.toChar + println(ClassTag.Char.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Char.unapply(x)) + test(x) + } + + { + val x = 1.toInt + println(ClassTag.Int.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Int.unapply(x)) + test(x) + } + + { + val x = 1.toLong + println(ClassTag.Long.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Long.unapply(x)) + test(x) + } + + { + val x = 1.toFloat + println(ClassTag.Float.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Float.unapply(x)) + test(x) + } + + { + val x = 1.toDouble + println(ClassTag.Double.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Double.unapply(x)) + test(x) + } + + { + val x = true + println(ClassTag.Boolean.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Boolean.unapply(x)) + test(x) + } + + { + val x = () + println(ClassTag.Unit.runtimeClass.isAssignableFrom(x.getClass)) + println(ClassTag.Unit.unapply(x)) + test(x) + } +}
\ No newline at end of file diff --git a/test/files/run/t6327.check b/test/files/run/t6327.check new file mode 100644 index 0000000000..f7bacac931 --- /dev/null +++ b/test/files/run/t6327.check @@ -0,0 +1,4 @@ +A +A +A +A diff --git a/test/files/run/t6327.scala b/test/files/run/t6327.scala new file mode 100644 index 0000000000..7683101f14 --- /dev/null +++ b/test/files/run/t6327.scala @@ -0,0 +1,22 @@ +import language._ + +object Test extends App { + + case class R[+T](s: String) { def x() = println(s) } + + // Implicits in contention; StringR is nested to avoid ambiguity + object R { implicit val StringR = R[String]("A") } + implicit val Default = R[Any]("B") + + class B() extends Dynamic { + def selectDynamic[T](f: String)(implicit r: R[T]): Unit = r.x() + } + + val b = new B() + + // These should all produce the same output, but they don't + b.selectDynamic[String]("baz") + b.baz[String] + val c = b.selectDynamic[String]("baz") + val d = b.baz[String] +} diff --git a/test/files/run/t6333.scala b/test/files/run/t6333.scala new file mode 100644 index 0000000000..266d95ce69 --- /dev/null +++ b/test/files/run/t6333.scala @@ -0,0 +1,29 @@ +object Test extends App { + import util.Try + + val a = "apple" + def fail: String = throw new Exception("Fail!") + def argh: Try[String] = throw new Exception("Argh!") + + // No throw tests + def tryMethods(expr: => String): Unit = { + Try(expr) orElse argh + Try(expr).transform(_ => argh, _ => argh) + Try(expr).recoverWith { case e if (a == fail) => Try(a) } + Try(expr).recoverWith { case _ => argh } + Try(expr).getOrElse(a) + // TODO - Fail getOrElse? + Try(expr) orElse argh + Try(expr) orElse Try(a) + Try(expr) map (_ => fail) + Try(expr) map (_ => a) + Try(expr) flatMap (_ => argh) + Try(expr) flatMap (_ => Try(a)) + Try(expr) filter (_ => throw new Exception("O NOES")) + Try(expr) filter (_ => true) + Try(expr) recover { case _ => fail } + Try(expr).failed + } + tryMethods(a) + tryMethods(fail) +} diff --git a/test/files/run/valueclasses-classtag-basic.check b/test/files/run/valueclasses-classtag-basic.check index 0c13986b32..554c75e074 100644 --- a/test/files/run/valueclasses-classtag-basic.check +++ b/test/files/run/valueclasses-classtag-basic.check @@ -1 +1 @@ -ClassTag[class Foo]
+Foo
diff --git a/test/files/run/valueclasses-classtag-existential.check b/test/files/run/valueclasses-classtag-existential.check index 95e94e7aee..15ac02630f 100644 --- a/test/files/run/valueclasses-classtag-existential.check +++ b/test/files/run/valueclasses-classtag-existential.check @@ -1 +1 @@ -ClassTag[class java.lang.Object]
+Object
diff --git a/test/files/run/valueclasses-classtag-generic.check b/test/files/run/valueclasses-classtag-generic.check index 0c13986b32..554c75e074 100644 --- a/test/files/run/valueclasses-classtag-generic.check +++ b/test/files/run/valueclasses-classtag-generic.check @@ -1 +1 @@ -ClassTag[class Foo]
+Foo
diff --git a/test/files/run/virtpatmat_typetag.check b/test/files/run/virtpatmat_typetag.check index f9800b84d0..eaa9f3361f 100644 --- a/test/files/run/virtpatmat_typetag.check +++ b/test/files/run/virtpatmat_typetag.check @@ -1,10 +1,10 @@ -1 is not a ClassTag[int]; it's a class java.lang.Integer -1 is a ClassTag[class java.lang.Integer] -1 is not a ClassTag[class java.lang.String]; it's a class java.lang.Integer -true is a ClassTag[class java.lang.Object] -woele is a ClassTag[class java.lang.String] -1 is not a ClassTag[int]; it's a class java.lang.Integer -1 is a ClassTag[class java.lang.Integer] -1 is not a ClassTag[class java.lang.String]; it's a class java.lang.Integer -true is a ClassTag[class java.lang.Object] -woele is a ClassTag[class java.lang.String] +1 is not a Int; it's a class java.lang.Integer
+1 is a java.lang.Integer
+1 is not a java.lang.String; it's a class java.lang.Integer
+true is a Any
+woele is a java.lang.String
+1 is not a Int; it's a class java.lang.Integer
+1 is a java.lang.Integer
+1 is not a java.lang.String; it's a class java.lang.Integer
+true is a Any
+woele is a java.lang.String
|