diff options
Diffstat (limited to 'test')
37 files changed, 263 insertions, 118 deletions
diff --git a/test/files/neg/t7325.check b/test/files/neg/t7325.check index 709ab6db3e..d2c40f4df8 100644 --- a/test/files/neg/t7325.check +++ b/test/files/neg/t7325.check @@ -1,19 +1,19 @@ -t7325.scala:2: error: percent signs not directly following splicees must be escaped +t7325.scala:2: error: conversions must follow a splice; use %% for literal %, %n for newline println(f"%") ^ -t7325.scala:4: error: percent signs not directly following splicees must be escaped +t7325.scala:4: error: conversions must follow a splice; use %% for literal %, %n for newline println(f"%%%") ^ -t7325.scala:6: error: percent signs not directly following splicees must be escaped +t7325.scala:6: error: conversions must follow a splice; use %% for literal %, %n for newline println(f"%%%%%") ^ t7325.scala:16: error: wrong conversion string println(f"${0}%") ^ -t7325.scala:19: error: percent signs not directly following splicees must be escaped +t7325.scala:19: error: conversions must follow a splice; use %% for literal %, %n for newline println(f"${0}%%%d") ^ -t7325.scala:21: error: percent signs not directly following splicees must be escaped +t7325.scala:21: error: conversions must follow a splice; use %% for literal %, %n for newline println(f"${0}%%%%%d") ^ 6 errors found diff --git a/test/files/pos/erasure-nsquared.scala b/test/files/pos/erasure-nsquared.scala new file mode 100644 index 0000000000..b0e30ade58 --- /dev/null +++ b/test/files/pos/erasure-nsquared.scala @@ -0,0 +1,35 @@ +trait BigCast { + def bar(x: Int): AnyRef = ( + null + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + .asInstanceOf[List[AnyRef]].head + ) +} diff --git a/test/files/pos/t7690.scala b/test/files/pos/t7690.scala new file mode 100644 index 0000000000..e8911a93e8 --- /dev/null +++ b/test/files/pos/t7690.scala @@ -0,0 +1,17 @@ +object A +trait B[T] + +object C { + implicit def notUsed[L[x]](in: L[Int]): B[L[Int]] = ??? + + class E(val ls: Int) { + def x(f: Int => Boolean): Boolean = f(ls) + } + implicit def isUsed(ls: Int): E = new E(ls) + + def amethod(in: Int): Boolean = + in.x { i => + import A._ + "asdf" == i.toString + } +}
\ No newline at end of file diff --git a/test/files/run/interpolation.flags b/test/files/run/interpolation.flags deleted file mode 100644 index 48fd867160..0000000000 --- a/test/files/run/interpolation.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/run/interpolationArgs.check b/test/files/run/interpolationArgs.check index 155991e618..983214cbee 100644 --- a/test/files/run/interpolationArgs.check +++ b/test/files/run/interpolationArgs.check @@ -1,2 +1,2 @@ -java.lang.IllegalArgumentException: wrong number of arguments for interpolated string -java.lang.IllegalArgumentException: wrong number of arguments for interpolated string +java.lang.IllegalArgumentException: wrong number of arguments (1) for interpolated string with 3 parts +java.lang.IllegalArgumentException: wrong number of arguments (1) for interpolated string with 1 parts diff --git a/test/files/run/interpolationArgs.flags b/test/files/run/interpolationArgs.flags deleted file mode 100644 index e1b37447c9..0000000000 --- a/test/files/run/interpolationArgs.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental
\ No newline at end of file diff --git a/test/files/run/interpolationMultiline1.flags b/test/files/run/interpolationMultiline1.flags deleted file mode 100644 index 48fd867160..0000000000 --- a/test/files/run/interpolationMultiline1.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/run/interpolationMultiline2.flags b/test/files/run/interpolationMultiline2.flags deleted file mode 100644 index e1b37447c9..0000000000 --- a/test/files/run/interpolationMultiline2.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental
\ No newline at end of file diff --git a/test/files/run/repl-javap-app.check b/test/files/run/repl-javap-app.check index db1f09b977..490860585c 100644 --- a/test/files/run/repl-javap-app.check +++ b/test/files/run/repl-javap-app.check @@ -6,14 +6,13 @@ scala> :javap -app MyApp$ public final void delayedEndpoint$MyApp$1(); Code: Stack=2, Locals=1, Args_size=1 - 0: getstatic #61; //Field scala/Console$.MODULE$:Lscala/Console$; - 3: ldc #63; //String Hello, delayed world. - 5: invokevirtual #67; //Method scala/Console$.println:(Ljava/lang/Object;)V - 8: return + 0: getstatic #61; //Field scala/Console$.MODULE$:Lscala/Console$; + 3: ldc #63; //String Hello, delayed world. + 5: invokevirtual #67; //Method scala/Console$.println:(Ljava/lang/Object;)V + 8: return LocalVariableTable: Start Length Slot Name Signature 0 9 0 this LMyApp$; -} scala> #partest !java6 diff --git a/test/files/run/stream_length.check b/test/files/run/stream_length.check index d1068f3247..e4350aa741 100644 --- a/test/files/run/stream_length.check +++ b/test/files/run/stream_length.check @@ -1,6 +1,5 @@ #partest !avian Length: 970299 - #partest avian !!!TEST SKIPPED!!! See SI-7600 for further information. diff --git a/test/files/run/t7265.scala b/test/files/run/t7265.scala deleted file mode 100644 index c556930303..0000000000 --- a/test/files/run/t7265.scala +++ /dev/null @@ -1,27 +0,0 @@ - -import scala.util.Properties._ - -object Test extends App { - - setProp("java.specification.version", "1.7") - - assert( isJavaAtLeast("1.5")) - assert( isJavaAtLeast("1.6")) - assert( isJavaAtLeast("1.7")) - assert(!isJavaAtLeast("1.8")) - assert(!isJavaAtLeast("1.71")) - - failing(isJavaAtLeast("1.a")) - failing(isJavaAtLeast("1")) - failing(isJavaAtLeast("")) - failing(isJavaAtLeast(".")) - failing(isJavaAtLeast(".5")) - failing(isJavaAtLeast("1.7.1")) - - def failing(u: =>Unit) = try { - u - assert(false, "Expected Exception") - } catch { - case _: NumberFormatException => - } -} diff --git a/test/files/run/tailcalls.check b/test/files/run/tailcalls.check index 10384ac46e..ab54d528ab 100644 --- a/test/files/run/tailcalls.check +++ b/test/files/run/tailcalls.check @@ -52,7 +52,6 @@ test TailCall.b2 was successful test FancyTailCalls.tcTryLocal was successful test FancyTailCalls.differentInstance was successful test PolyObject.tramp was successful - #partest avian test Object .f was successful test Final .f was successful @@ -106,4 +105,4 @@ test TailCall.b1 was successful test TailCall.b2 was successful test FancyTailCalls.tcTryLocal was successful test FancyTailCalls.differentInstance was successful -test PolyObject.tramp was successful
\ No newline at end of file +test PolyObject.tramp was successful diff --git a/test/files/scalacheck/CheckCollections.scala b/test/files/scalacheck/CheckCollections.scala new file mode 100644 index 0000000000..108040b900 --- /dev/null +++ b/test/files/scalacheck/CheckCollections.scala @@ -0,0 +1,59 @@ +import org.scalacheck.{ ConsoleReporter, Properties } +import org.scalacheck.Prop._ + +import scala.reflect.internal.util.Collections._ + +object Test extends Properties("reflect.internal.util.Collections") { + def map2ConserveOld[A <: AnyRef, B](xs: List[A], ys: List[B])(f: (A, B) => A): List[A] = + if (xs.isEmpty || ys.isEmpty) xs + else { + val x1 = f(xs.head, ys.head) + val xs1 = map2Conserve(xs.tail, ys.tail)(f) + if ((x1 eq xs.head) && (xs1 eq xs.tail)) xs + else x1 :: xs1 + } + + val testfun: (String, Int) => String = { case(x, y) => + x.toLowerCase + y.toString + } + val testid: (String, Int) => String = { case (x, y) => x } + + val prop1_map2Conserve = forAll { (xs: List[String], ys: List[Int]) => + val res = map2Conserve(xs, ys)(testid) + res eq xs + } + + val prop2_map2Conserve = forAll { (xs: List[String], ys: List[Int]) => + map2Conserve(xs, ys)(testid) == map2ConserveOld(xs, ys)(testid) && + map2Conserve(xs, ys)(testfun) == map2ConserveOld(xs, ys)(testfun) + } + + def checkStackOverflow() { + var xs: List[String] = Nil + var ys: List[Int] = Nil + for (i <- 0 until 250000) { + xs = "X" :: xs + ys = 1 :: ys + } + map2Conserve(xs, ys){ case(x, y) => x.toLowerCase + y.toString } + } + + + val tests = List( + ("map2Conserve(identity)", prop1_map2Conserve), + ("map2Conserve == old impl", prop2_map2Conserve) + ) + + checkStackOverflow() + + for { + (label, prop) <- tests + } property(label) = prop + + import org.scalacheck.{ Test => STest } + + def runTests() = + STest.checkProperties( + STest.Params(testCallback = ConsoleReporter(0)), this) + +} diff --git a/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala b/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala index 03f8aa58d3..23b6a5fbdb 100644 --- a/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala +++ b/test/files/scalacheck/quasiquotes/ArbitraryTreesAndNames.scala @@ -91,7 +91,7 @@ trait ArbitraryTreesAndNames { yield CompoundTypeTree(templ) def genDefDef(size: Int) = - for(mods <- genModifiers; name <- genName; + for(mods <- genModifiers; name <- genTermName; tpt <- genTree(size -1); rhs <- genTree(size - 1); tparams <- smallList(size, genTypeDef(size - 1)); vparamss <- smallList(size, smallList(size, genValDef(size - 1)))) diff --git a/test/files/scalap/abstractClass.check b/test/files/scalap/abstractClass.check index ef1daac23d..95e80ac3c9 100644 --- a/test/files/scalap/abstractClass.check +++ b/test/files/scalap/abstractClass.check @@ -1,4 +1,4 @@ abstract class AbstractClass extends scala.AnyRef { def this() = { /* compiled code */ } - def foo : scala.Predef.String + def foo: scala.Predef.String } diff --git a/test/files/scalap/abstractMethod.check b/test/files/scalap/abstractMethod.check index 40fa02d408..0d0b1b7421 100644 --- a/test/files/scalap/abstractMethod.check +++ b/test/files/scalap/abstractMethod.check @@ -1,5 +1,5 @@ trait AbstractMethod extends scala.AnyRef { - def $init$() : scala.Unit = { /* compiled code */ } - def arity : scala.Int - def isCool : scala.Boolean = { /* compiled code */ } + def $init$(): scala.Unit = { /* compiled code */ } + def arity: scala.Int + def isCool: scala.Boolean = { /* compiled code */ } } diff --git a/test/files/scalap/caseClass.check b/test/files/scalap/caseClass.check index 7d7aa4fd8f..51ad90d9b2 100644 --- a/test/files/scalap/caseClass.check +++ b/test/files/scalap/caseClass.check @@ -1,20 +1,20 @@ -case class CaseClass[A <: scala.Seq[scala.Int]](i : A, s : scala.Predef.String) extends scala.AnyRef with scala.Product with scala.Serializable { - val i : A = { /* compiled code */ } - val s : scala.Predef.String = { /* compiled code */ } - def foo : scala.Int = { /* compiled code */ } - def copy[A <: scala.Seq[scala.Int]](i : A, s : scala.Predef.String) : CaseClass[A] = { /* compiled code */ } - override def productPrefix : java.lang.String = { /* compiled code */ } - def productArity : scala.Int = { /* compiled code */ } - def productElement(x$1 : scala.Int) : scala.Any = { /* compiled code */ } - override def productIterator : scala.collection.Iterator[scala.Any] = { /* compiled code */ } - def canEqual(x$1 : scala.Any) : scala.Boolean = { /* compiled code */ } - override def hashCode() : scala.Int = { /* compiled code */ } - override def toString() : java.lang.String = { /* compiled code */ } - override def equals(x$1 : scala.Any) : scala.Boolean = { /* compiled code */ } +case class CaseClass[A <: scala.Seq[scala.Int]](i: A, s: scala.Predef.String) extends scala.AnyRef with scala.Product with scala.Serializable { + val i: A = { /* compiled code */ } + val s: scala.Predef.String = { /* compiled code */ } + def foo: scala.Int = { /* compiled code */ } + def copy[A <: scala.Seq[scala.Int]](i: A, s: scala.Predef.String): CaseClass[A] = { /* compiled code */ } + override def productPrefix: java.lang.String = { /* compiled code */ } + def productArity: scala.Int = { /* compiled code */ } + def productElement(x$1: scala.Int): scala.Any = { /* compiled code */ } + override def productIterator: scala.collection.Iterator[scala.Any] = { /* compiled code */ } + def canEqual(x$1: scala.Any): scala.Boolean = { /* compiled code */ } + override def hashCode(): scala.Int = { /* compiled code */ } + override def toString(): java.lang.String = { /* compiled code */ } + override def equals(x$1: scala.Any): scala.Boolean = { /* compiled code */ } } object CaseClass extends scala.AnyRef with scala.Serializable { def this() = { /* compiled code */ } - final override def toString() : java.lang.String = { /* compiled code */ } - def apply[A <: scala.Seq[scala.Int]](i : A, s : scala.Predef.String) : CaseClass[A] = { /* compiled code */ } - def unapply[A <: scala.Seq[scala.Int]](x$0 : CaseClass[A]) : scala.Option[scala.Tuple2[A, scala.Predef.String]] = { /* compiled code */ } + final override def toString(): java.lang.String = { /* compiled code */ } + def apply[A <: scala.Seq[scala.Int]](i: A, s: scala.Predef.String): CaseClass[A] = { /* compiled code */ } + def unapply[A <: scala.Seq[scala.Int]](x$0: CaseClass[A]): scala.Option[scala.Tuple2[A, scala.Predef.String]] = { /* compiled code */ } } diff --git a/test/files/scalap/caseObject.check b/test/files/scalap/caseObject.check index 867a4b2162..a342e5ff1a 100644 --- a/test/files/scalap/caseObject.check +++ b/test/files/scalap/caseObject.check @@ -1,10 +1,10 @@ case object CaseObject extends scala.AnyRef with scala.Product with scala.Serializable { - def bar : scala.Int = { /* compiled code */ } - override def productPrefix : java.lang.String = { /* compiled code */ } - def productArity : scala.Int = { /* compiled code */ } - def productElement(x$1 : scala.Int) : scala.Any = { /* compiled code */ } - override def productIterator : scala.collection.Iterator[scala.Any] = { /* compiled code */ } - def canEqual(x$1 : scala.Any) : scala.Boolean = { /* compiled code */ } - override def hashCode() : scala.Int = { /* compiled code */ } - override def toString() : java.lang.String = { /* compiled code */ } + def bar: scala.Int = { /* compiled code */ } + override def productPrefix: java.lang.String = { /* compiled code */ } + def productArity: scala.Int = { /* compiled code */ } + def productElement(x$1: scala.Int): scala.Any = { /* compiled code */ } + override def productIterator: scala.collection.Iterator[scala.Any] = { /* compiled code */ } + def canEqual(x$1: scala.Any): scala.Boolean = { /* compiled code */ } + override def hashCode(): scala.Int = { /* compiled code */ } + override def toString(): java.lang.String = { /* compiled code */ } } diff --git a/test/files/scalap/cbnParam.check b/test/files/scalap/cbnParam.check index 52ecb6ae66..abe01297b9 100644 --- a/test/files/scalap/cbnParam.check +++ b/test/files/scalap/cbnParam.check @@ -1,3 +1,3 @@ class CbnParam extends scala.AnyRef { - def this(s : => scala.Predef.String) = { /* compiled code */ } + def this(s: => scala.Predef.String) = { /* compiled code */ } } diff --git a/test/files/scalap/classPrivate.check b/test/files/scalap/classPrivate.check index ab2d40cdaf..cf0ffe0cb2 100644 --- a/test/files/scalap/classPrivate.check +++ b/test/files/scalap/classPrivate.check @@ -1,10 +1,10 @@ class ClassPrivate extends scala.AnyRef { def this() = { /* compiled code */ } - def baz : scala.Int = { /* compiled code */ } + def baz: scala.Int = { /* compiled code */ } class Outer extends scala.AnyRef { def this() = { /* compiled code */ } - private[ClassPrivate] def qux : scala.Int = { /* compiled code */ } + private[ClassPrivate] def qux: scala.Int = { /* compiled code */ } } - protected def quux : scala.Int = { /* compiled code */ } - private[ClassPrivate] def bar : scala.Int = { /* compiled code */ } + protected def quux: scala.Int = { /* compiled code */ } + private[ClassPrivate] def bar: scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/classWithExistential.check b/test/files/scalap/classWithExistential.check index caee3fd6de..7df6bfb765 100644 --- a/test/files/scalap/classWithExistential.check +++ b/test/files/scalap/classWithExistential.check @@ -1,4 +1,4 @@ class ClassWithExistential extends scala.AnyRef { def this() = { /* compiled code */ } - def foo[A, B] : scala.Function1[A, B forSome {type A <: scala.Seq[scala.Int]; type B >: scala.Predef.String}] = { /* compiled code */ } + def foo[A, B]: scala.Function1[A, B forSome {type A <: scala.Seq[scala.Int]; type B >: scala.Predef.String}] = { /* compiled code */ } } diff --git a/test/files/scalap/classWithSelfAnnotation.check b/test/files/scalap/classWithSelfAnnotation.check index 82bbd9e8df..7a1c206e33 100644 --- a/test/files/scalap/classWithSelfAnnotation.check +++ b/test/files/scalap/classWithSelfAnnotation.check @@ -1,5 +1,5 @@ class ClassWithSelfAnnotation extends scala.AnyRef { - this : ClassWithSelfAnnotation with java.lang.CharSequence => + this: ClassWithSelfAnnotation with java.lang.CharSequence => def this() = { /* compiled code */ } - def foo : scala.Int = { /* compiled code */ } + def foo: scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/covariantParam.check b/test/files/scalap/covariantParam.check index f7a3c98966..85b1400fce 100644 --- a/test/files/scalap/covariantParam.check +++ b/test/files/scalap/covariantParam.check @@ -1,4 +1,4 @@ class CovariantParam[+A] extends scala.AnyRef { def this() = { /* compiled code */ } - def foo[A](a : A) : scala.Int = { /* compiled code */ } + def foo[A](a: A): scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/defaultParameter.check b/test/files/scalap/defaultParameter.check index 0c775ea7b5..4e244d18f1 100644 --- a/test/files/scalap/defaultParameter.check +++ b/test/files/scalap/defaultParameter.check @@ -1,3 +1,3 @@ trait DefaultParameter extends scala.AnyRef { - def foo(s : scala.Predef.String) : scala.Unit + def foo(s: scala.Predef.String): scala.Unit } diff --git a/test/files/scalap/implicitParam.check b/test/files/scalap/implicitParam.check index a2cfd6092d..46e995652e 100644 --- a/test/files/scalap/implicitParam.check +++ b/test/files/scalap/implicitParam.check @@ -1,4 +1,4 @@ class ImplicitParam extends scala.AnyRef { def this() = { /* compiled code */ } - def foo(i : scala.Int)(implicit f : scala.Float, d : scala.Double) : scala.Int = { /* compiled code */ } + def foo(i: scala.Int)(implicit f: scala.Float, d: scala.Double): scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/packageObject.check b/test/files/scalap/packageObject.check index 5732d92958..d1d0bbf122 100644 --- a/test/files/scalap/packageObject.check +++ b/test/files/scalap/packageObject.check @@ -1,5 +1,5 @@ package object PackageObject extends scala.AnyRef { def this() = { /* compiled code */ } type A = scala.Predef.String - def foo(i : scala.Int) : scala.Int = { /* compiled code */ } + def foo(i: scala.Int): scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/paramClauses.check b/test/files/scalap/paramClauses.check index 3a141e8faf..11c5e4bbd6 100644 --- a/test/files/scalap/paramClauses.check +++ b/test/files/scalap/paramClauses.check @@ -1,4 +1,4 @@ class ParamClauses extends scala.AnyRef { def this() = { /* compiled code */ } - def foo(i : scala.Int)(s : scala.Predef.String)(t : scala.Double) : scala.Int = { /* compiled code */ } + def foo(i: scala.Int)(s: scala.Predef.String)(t: scala.Double): scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/paramNames.check b/test/files/scalap/paramNames.check index 85e37f858d..836b3d0e7b 100644 --- a/test/files/scalap/paramNames.check +++ b/test/files/scalap/paramNames.check @@ -1,4 +1,4 @@ class ParamNames extends scala.AnyRef { def this() = { /* compiled code */ } - def foo(s : => scala.Seq[scala.Int], s2 : => scala.Seq[scala.Any]) : scala.Unit = { /* compiled code */ } + def foo(s: => scala.Seq[scala.Int], s2: => scala.Seq[scala.Any]): scala.Unit = { /* compiled code */ } } diff --git a/test/files/scalap/sequenceParam.check b/test/files/scalap/sequenceParam.check index 142d92fea3..f7bf83f6b2 100644 --- a/test/files/scalap/sequenceParam.check +++ b/test/files/scalap/sequenceParam.check @@ -1,3 +1,3 @@ class SequenceParam extends scala.AnyRef { - def this(s : scala.Predef.String, i : scala.Int*) = { /* compiled code */ } + def this(s: scala.Predef.String, i: scala.Int*) = { /* compiled code */ } } diff --git a/test/files/scalap/simpleClass.check b/test/files/scalap/simpleClass.check index 4fdf25d1cf..4675cbf665 100644 --- a/test/files/scalap/simpleClass.check +++ b/test/files/scalap/simpleClass.check @@ -1,4 +1,4 @@ class SimpleClass extends scala.AnyRef { def this() = { /* compiled code */ } - def foo : scala.Int = { /* compiled code */ } + def foo: scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/traitObject.check b/test/files/scalap/traitObject.check index 104ba14f1a..f7ae4fd2f4 100644 --- a/test/files/scalap/traitObject.check +++ b/test/files/scalap/traitObject.check @@ -1,8 +1,8 @@ trait TraitObject extends scala.AnyRef { - def $init$() : scala.Unit = { /* compiled code */ } - def foo : scala.Int = { /* compiled code */ } + def $init$(): scala.Unit = { /* compiled code */ } + def foo: scala.Int = { /* compiled code */ } } object TraitObject extends scala.AnyRef { def this() = { /* compiled code */ } - def bar : scala.Int = { /* compiled code */ } + def bar: scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/typeAnnotations.check b/test/files/scalap/typeAnnotations.check index 407b0235c6..cba69f8e41 100644 --- a/test/files/scalap/typeAnnotations.check +++ b/test/files/scalap/typeAnnotations.check @@ -1,8 +1,8 @@ abstract class TypeAnnotations[@scala.specialized R] extends scala.AnyRef { def this() = { /* compiled code */ } @scala.specialized - val x : scala.Int = { /* compiled code */ } + val x: scala.Int = { /* compiled code */ } @scala.specialized type T - def compose[@scala.specialized A](x : A, y : R) : A = { /* compiled code */ } + def compose[@scala.specialized A](x: A, y: R): A = { /* compiled code */ } } diff --git a/test/files/scalap/valAndVar.check b/test/files/scalap/valAndVar.check index e940da9801..98eae5192d 100644 --- a/test/files/scalap/valAndVar.check +++ b/test/files/scalap/valAndVar.check @@ -1,5 +1,5 @@ class ValAndVar extends scala.AnyRef { def this() = { /* compiled code */ } - val foo : java.lang.String = { /* compiled code */ } - var bar : scala.Int = { /* compiled code */ } + val foo: java.lang.String = { /* compiled code */ } + var bar: scala.Int = { /* compiled code */ } } diff --git a/test/files/scalap/wildcardType.check b/test/files/scalap/wildcardType.check index e43261db32..6ea696647e 100644 --- a/test/files/scalap/wildcardType.check +++ b/test/files/scalap/wildcardType.check @@ -1,3 +1,3 @@ class WildcardType extends scala.AnyRef { - def this(f : scala.Function1[scala.Int, _]) = { /* compiled code */ } + def this(f: scala.Function1[scala.Int, _]) = { /* compiled code */ } } diff --git a/test/junit/scala/util/matching/regextract-char.scala b/test/junit/scala/util/matching/regextract-char.scala new file mode 100644 index 0000000000..50fdcd9d46 --- /dev/null +++ b/test/junit/scala/util/matching/regextract-char.scala @@ -0,0 +1,58 @@ + +package scala.util.matching + +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +import PartialFunction._ + +/** Regex can match a Char. + * If the pattern includes a group, + * always return a single char. + */ +@RunWith(classOf[JUnit4]) +class CharRegexTest { + implicit class Averrable(val b: Boolean) /*extends AnyVal*/ { + def yes = assert(b) + def no = assert(!b) + } + val c: Char = 'c' // "cat"(0) + val d: Char = 'D' // "Dog"(0) + + @Test def comparesGroupCorrectly(): Unit = { + val r = """(\p{Lower})""".r + cond(c) { case r(x) => true } .yes + cond(c) { case r(_) => true } .yes + cond(c) { case r(_*) => true } .yes + cond(c) { case r() => true } .no + + cond(d) { case r(x) => true } .no + cond(d) { case r(_) => true } .no + cond(d) { case r(_*) => true } .no + cond(d) { case r() => true } .no + } + + @Test def comparesNoGroupCorrectly(): Unit = { + val rnc = """\p{Lower}""".r + cond(c) { case rnc(x) => true } .no + cond(c) { case rnc(_) => true } .no + cond(c) { case rnc(_*) => true } .yes + cond(c) { case rnc() => true } .yes + + cond(d) { case rnc(x) => true } .no + cond(d) { case rnc(_) => true } .no + cond(d) { case rnc(_*) => true } .no + cond(d) { case rnc() => true } .no + } + + @Test(expected = classOf[MatchError]) + def failCorrectly(): Unit = { + val headAndTail = """(\p{Lower})([a-z]+)""".r + val n = "cat"(0) match { + case headAndTail(ht @ _*) => ht.size + } + assert(false, s"Match size $n") + } +} diff --git a/test/pending/junit/scala/util/t7265.scala b/test/junit/scala/util/t7265.scala index 3b8fa80dbe..71f085d21d 100644 --- a/test/pending/junit/scala/util/t7265.scala +++ b/test/junit/scala/util/t7265.scala @@ -30,6 +30,7 @@ class SpecVersionTest { assert(sut isJavaAtLeast "1.6") assert(sut isJavaAtLeast "1.7") assert(!(sut isJavaAtLeast "1.8")) + assert(!(sut isJavaAtLeast "1.71")) } @Test(expected = classOf[NumberFormatException]) def badVersion(): Unit = { @@ -40,6 +41,18 @@ class SpecVersionTest { sut isJavaAtLeast "1" } @Test(expected = classOf[NumberFormatException]) + def noVersion(): Unit = { + sut isJavaAtLeast "" + } + @Test(expected = classOf[NumberFormatException]) + def dotOnly(): Unit = { + sut isJavaAtLeast "." + } + @Test(expected = classOf[NumberFormatException]) + def leadingDot(): Unit = { + sut isJavaAtLeast ".5" + } + @Test(expected = classOf[NumberFormatException]) def notASpec(): Unit = { sut isJavaAtLeast "1.7.1" } diff --git a/test/partest b/test/partest index 0259cdb791..8d94facba3 100755 --- a/test/partest +++ b/test/partest @@ -1,6 +1,5 @@ #!/usr/bin/env bash # - ############################################################################## # Scala test runner 2.10.0 ############################################################################## @@ -11,6 +10,17 @@ # PARTICULAR PURPOSE. ############################################################################## +findScalaHome () { + # see SI-2092 and SI-5792 + local source="${BASH_SOURCE[0]}" + while [ -h "$source" ] ; do + local linked="$(readlink "$source")" + local dir="$( cd -P $(dirname "$source") && cd -P $(dirname "$linked") && pwd )" + source="$dir/$(basename "$linked")" + done + ( ( cd -P "$(dirname "$source")/.." > /dev/null ) && pwd ) +} + # Use tput to detect color-capable terminal. term_colors=$(tput colors 2>/dev/null) if [[ $? == 0 ]] && [[ $term_colors -gt 2 ]]; then @@ -29,23 +39,7 @@ case "`uname`" in esac # Finding the root folder for this Scala distribution -SOURCE=$0; -SCRIPT=`basename "$SOURCE"`; -while [ -h "$SOURCE" ]; do - SCRIPT=`basename "$SOURCE"`; - LOOKUP=`ls -ld "$SOURCE"`; - TARGET=`expr "$LOOKUP" : '.*-> \(.*\)$'`; - if expr "${TARGET:-.}/" : '/.*/$' > /dev/null; then - SOURCE=${TARGET:-.}; - else - SOURCE=`dirname "$SOURCE"`/${TARGET:-.}; - fi; -done; - -# see #2092 -SCALA_HOME=`dirname "$SOURCE"` -SCALA_HOME=`cd "$SCALA_HOME"; pwd -P` -SCALA_HOME=`cd "$SCALA_HOME"/..; pwd` +SCALA_HOME="$(findScalaHome)" if $cygwin; then SCALA_HOME=`cygpath --windows --short-name "$SCALA_HOME"` @@ -125,10 +119,13 @@ if [ ! -z "${PARTEST_DEBUG}" ] ; then partestDebugStr="-Dpartest.debug=${PARTEST_DEBUG}" fi +# note that variables which may intentionally be empty must not +# be quoted: otherwise an empty string will appear as a command line +# argument, and java will think that is the program to run. "${JAVACMD:=java}" \ $JAVA_OPTS -cp "$EXT_CLASSPATH" \ ${partestDebugStr} \ - "$color_opts" \ + ${color_opts} \ -Dfile.encoding=UTF-8 \ -Dscala.home="${SCALA_HOME}" \ -Dpartest.javacmd="${JAVACMD}" \ |