diff options
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/jvm/serialization-new.check | 2 | ||||
-rw-r--r-- | test/files/jvm/serialization.check | 2 | ||||
-rw-r--r-- | test/files/neg/t7623.check | 21 | ||||
-rw-r--r-- | test/files/neg/t7623.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t7623.scala | 38 | ||||
-rw-r--r-- | test/files/neg/t9041.check | 4 | ||||
-rw-r--r-- | test/files/neg/t9041.scala | 17 | ||||
-rw-r--r-- | test/files/neg/t9093.check | 6 | ||||
-rw-r--r-- | test/files/neg/t9093.scala | 5 | ||||
-rw-r--r-- | test/files/pos/t5154.scala | 9 | ||||
-rw-r--r-- | test/files/pos/t9050.scala | 13 | ||||
-rw-r--r-- | test/files/pos/t9086.scala | 8 | ||||
-rw-r--r-- | test/files/pos/t9123.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t9123.scala | 10 | ||||
-rw-r--r-- | test/files/pos/t9135.scala | 16 | ||||
-rw-r--r-- | test/files/run/bitsets.check | 1 | ||||
-rw-r--r-- | test/files/run/t6502.check | 8 | ||||
-rw-r--r-- | test/files/run/t6502.scala | 70 | ||||
-rw-r--r-- | test/files/scalacheck/nan-ordering.scala | 16 |
19 files changed, 210 insertions, 38 deletions
diff --git a/test/files/jvm/serialization-new.check b/test/files/jvm/serialization-new.check index 1555135926..cb26446f40 100644 --- a/test/files/jvm/serialization-new.check +++ b/test/files/jvm/serialization-new.check @@ -1,4 +1,4 @@ -warning: there were two deprecation warnings; re-run with -deprecation for details +warning: there were three deprecation warnings; re-run with -deprecation for details a1 = Array[1,2,3] _a1 = Array[1,2,3] arrayEquals(a1, _a1): true diff --git a/test/files/jvm/serialization.check b/test/files/jvm/serialization.check index 1555135926..cb26446f40 100644 --- a/test/files/jvm/serialization.check +++ b/test/files/jvm/serialization.check @@ -1,4 +1,4 @@ -warning: there were two deprecation warnings; re-run with -deprecation for details +warning: there were three deprecation warnings; re-run with -deprecation for details a1 = Array[1,2,3] _a1 = Array[1,2,3] arrayEquals(a1, _a1): true diff --git a/test/files/neg/t7623.check b/test/files/neg/t7623.check new file mode 100644 index 0000000000..db368dd369 --- /dev/null +++ b/test/files/neg/t7623.check @@ -0,0 +1,21 @@ +t7623.scala:19: warning: A repeated case parameter or extracted sequence should be matched only by a sequence wildcard (_*). + def f = "" match { case X(s) => } + ^ +t7623.scala:21: warning: A repeated case parameter or extracted sequence should be matched only by a sequence wildcard (_*). + def g = "" match { case X(s, t) => } + ^ +t7623.scala:23: warning: A repeated case parameter or extracted sequence should be matched only by a sequence wildcard (_*). + def h = "" match { case X(s, t, u @ _*) => } + ^ +t7623.scala:9: warning: A repeated case parameter or extracted sequence should be matched only by a sequence wildcard (_*). + def f = C("") match { case C(s) => } + ^ +t7623.scala:11: warning: A repeated case parameter or extracted sequence should be matched only by a sequence wildcard (_*). + def g = C("") match { case C(s, t) => } + ^ +t7623.scala:13: warning: A repeated case parameter or extracted sequence should be matched only by a sequence wildcard (_*). + def h = C("") match { case C(s, t, u @ _*) => } + ^ +error: No warnings can be incurred under -Xfatal-warnings. +6 warnings found +one error found diff --git a/test/files/neg/t7623.flags b/test/files/neg/t7623.flags new file mode 100644 index 0000000000..74c9e38323 --- /dev/null +++ b/test/files/neg/t7623.flags @@ -0,0 +1 @@ +-Xlint:stars-align -Xfatal-warnings diff --git a/test/files/neg/t7623.scala b/test/files/neg/t7623.scala new file mode 100644 index 0000000000..5c40f37bc1 --- /dev/null +++ b/test/files/neg/t7623.scala @@ -0,0 +1,38 @@ + + +case class C(s: String, xs: Int*) + +object X { def unapplySeq(a: Any): Option[(String, Seq[Int])] = Some("", List(1,2,3)) } + +// for case classes with varargs, avoid misaligned patterns +trait Ctest { + def f = C("") match { case C(s) => } + + def g = C("") match { case C(s, t) => } + + def h = C("") match { case C(s, t, u @ _*) => } + + def ok = C("") match { case C(s, u @ _*) => } +} +// for extractors that unapplySeq: Option[(Something, Seq[_])], avoid misaligned patterns +trait Xtest { + def f = "" match { case X(s) => } + + def g = "" match { case X(s, t) => } + + def h = "" match { case X(s, t, u @ _*) => } + + def ok = "" match { case X(s, u @ _*) => } +} +// for extractors that unapplySeq: Option[Seq[_]], anything goes +trait Rtest { + val r = "(a+)".r + + def f = "" match { case r(s) => } + + def g = "" match { case r(s, t) => } + + def h = "" match { case r(s, t, u @ _*) => } + + def whatever = "" match { case r(u @ _*) => } +} diff --git a/test/files/neg/t9041.check b/test/files/neg/t9041.check new file mode 100644 index 0000000000..669e9434e0 --- /dev/null +++ b/test/files/neg/t9041.check @@ -0,0 +1,4 @@ +t9041.scala:11: error: could not find implicit value for parameter cellSetter: CellSetter[scala.math.BigDecimal] + def setCell(cell: Cell, data: math.BigDecimal) { cell.setCellValue(data) } + ^ +one error found diff --git a/test/files/neg/t9041.scala b/test/files/neg/t9041.scala new file mode 100644 index 0000000000..2bdef0d3ae --- /dev/null +++ b/test/files/neg/t9041.scala @@ -0,0 +1,17 @@ +// False negative test, requires overloading in Cell. + +trait Cell { def setCellValue(i: Int) = () ; def setCellValue(d: Double) = () } + +trait Nope { + def f = { + trait CellSetter[A] { + def setCell(cell: Cell, data: A): Unit + } + implicit val bigDecimalCellSetter = new CellSetter[math.BigDecimal]() { + def setCell(cell: Cell, data: math.BigDecimal) { cell.setCellValue(data) } + } + implicit class RichCell(cell: Cell) { + def setCellValue[A](data: A)(implicit cellSetter: CellSetter[A]) = cellSetter.setCell(cell, data) + } + } +} diff --git a/test/files/neg/t9093.check b/test/files/neg/t9093.check new file mode 100644 index 0000000000..085a433f0b --- /dev/null +++ b/test/files/neg/t9093.check @@ -0,0 +1,6 @@ +t9093.scala:3: error: polymorphic expression cannot be instantiated to expected type; + found : [C](f: C)Null + required: Unit + val x: Unit = apply2(0)/*(0)*/ + ^ +one error found diff --git a/test/files/neg/t9093.scala b/test/files/neg/t9093.scala new file mode 100644 index 0000000000..d9922ad70e --- /dev/null +++ b/test/files/neg/t9093.scala @@ -0,0 +1,5 @@ +object Main { + def apply2[C](fa: Any)(f: C) = null + val x: Unit = apply2(0)/*(0)*/ +} + diff --git a/test/files/pos/t5154.scala b/test/files/pos/t5154.scala new file mode 100644 index 0000000000..2629308f00 --- /dev/null +++ b/test/files/pos/t5154.scala @@ -0,0 +1,9 @@ + +trait Z { + // extra space made the pattern OK + def f = <z> {{3}}</z> match { case <z> {{3}}</z> => } + + // lack of space: error: illegal start of simple pattern + def g = <z>{{3}}</z> match { case <z>{{3}}</z> => } +} + diff --git a/test/files/pos/t9050.scala b/test/files/pos/t9050.scala new file mode 100644 index 0000000000..b1ab09f901 --- /dev/null +++ b/test/files/pos/t9050.scala @@ -0,0 +1,13 @@ +final class Mu[F](val value: Any) extends AnyVal { + def cata(f: F) { + // crash + ((y: Mu[F]) => y.cata(f)) + // crash + def foo(x : Mu[F]) = x.cata(f) + + // // okay + def x: Mu[F] = ??? + (() => x.cata(f)) + assert(true, cata(f)) + } +} diff --git a/test/files/pos/t9086.scala b/test/files/pos/t9086.scala new file mode 100644 index 0000000000..fba34ee226 --- /dev/null +++ b/test/files/pos/t9086.scala @@ -0,0 +1,8 @@ +class X[A](a: A) +object Test { + implicit val ImplicitBoolean: Boolean = true + def local = { + implicit object X extends X({ implicitly[Boolean] ; "" }) + implicitly[X[String]] // failed in 2.11.5 + } +} diff --git a/test/files/pos/t9123.flags b/test/files/pos/t9123.flags new file mode 100644 index 0000000000..c16e2f71dc --- /dev/null +++ b/test/files/pos/t9123.flags @@ -0,0 +1 @@ +-optimize -Ydelambdafy:method diff --git a/test/files/pos/t9123.scala b/test/files/pos/t9123.scala new file mode 100644 index 0000000000..22d55b4351 --- /dev/null +++ b/test/files/pos/t9123.scala @@ -0,0 +1,10 @@ +trait Setting { + type T + def value: T +} + +object Test { + def test(x: Some[Setting]) = x match { + case Some(dep) => Some(dep.value) map (_ => true) + } +} diff --git a/test/files/pos/t9135.scala b/test/files/pos/t9135.scala new file mode 100644 index 0000000000..1e2c97baf9 --- /dev/null +++ b/test/files/pos/t9135.scala @@ -0,0 +1,16 @@ + +class Free[A] { + + + this match { + case a @ Gosub() => gosub(a.a)(x => gosub(???)(???)) + } + def gosub[A, B](a0: Free[A])(f0: A => Any): Free[B] = ??? +} + + + + case class Gosub[B]() extends Free[B] { + type C + def a: Free[C] = ??? + } diff --git a/test/files/run/bitsets.check b/test/files/run/bitsets.check index 41c2ccdcb8..c24fd6238f 100644 --- a/test/files/run/bitsets.check +++ b/test/files/run/bitsets.check @@ -1,3 +1,4 @@ +warning: there were three deprecation warnings; re-run with -deprecation for details ms0 = BitSet(2) ms1 = BitSet(2) ms2 = BitSet(2) diff --git a/test/files/run/t6502.check b/test/files/run/t6502.check deleted file mode 100644 index 95d36ee221..0000000000 --- a/test/files/run/t6502.check +++ /dev/null @@ -1,8 +0,0 @@ -test1 res1: true -test1 res2: true -test2 res1: true -test2 res2: true -test3 res1: true -test3 res2: true -test4 res1: true -test4 res2: true diff --git a/test/files/run/t6502.scala b/test/files/run/t6502.scala index 4ce034a482..52fabef6b8 100644 --- a/test/files/run/t6502.scala +++ b/test/files/run/t6502.scala @@ -46,6 +46,12 @@ object Test extends StoreReporterDirectTest { } }""" + def app6 = """ + package test6 + class A extends Test { println("created test6.A") } + class Z extends Test { println("created test6.Z") } + trait Test""" + def test1(): Unit = { val jar = "test1.jar" compileCode(app1, jar) @@ -53,11 +59,12 @@ object Test extends StoreReporterDirectTest { val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar", "test.Test.test()") val output = ILoop.run(codeToRun, settings) val lines = output.split("\n") - val res1 = lines(4).contains("Added") && lines(4).contains("test1.jar") - val res2 = lines(lines.length-3).contains("testing...") - - println(s"test1 res1: $res1") - println(s"test1 res2: $res2") + assert { + lines(4).contains("Added") && lines(4).contains("test1.jar") + } + assert { + lines(lines.length-3).contains("testing...") + } } def test2(): Unit = { @@ -69,11 +76,12 @@ object Test extends StoreReporterDirectTest { val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar2") val output = ILoop.run(codeToRun, settings) val lines = output.split("\n") - val res1 = lines(4).contains("Added") && lines(4).contains("test1.jar") - val res2 = lines(lines.length-3).contains("test2.jar") && lines(lines.length-3).contains("existing classpath entries conflict") - - println(s"test2 res1: $res1") - println(s"test2 res2: $res2") + assert { + lines(4).contains("Added") && lines(4).contains("test1.jar") + } + assert { + lines(lines.length-3).contains("test2.jar") && lines(lines.length-3).contains("existing classpath entries conflict") + } } def test3(): Unit = { @@ -85,11 +93,12 @@ object Test extends StoreReporterDirectTest { val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar3", "test.Test3.test()") val output = ILoop.run(codeToRun, settings) val lines = output.split("\n") - val res1 = lines(4).contains("Added") && lines(4).contains("test1.jar") - val res2 = lines(lines.length-3).contains("new object in existing package") - - println(s"test3 res1: $res1") - println(s"test3 res2: $res2") + assert { + lines(4).contains("Added") && lines(4).contains("test1.jar") + } + assert { + lines(lines.length-3).contains("new object in existing package") + } } def test4(): Unit = { @@ -98,11 +107,30 @@ object Test extends StoreReporterDirectTest { val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar1") val output = ILoop.run(codeToRun, settings) val lines = output.split("\n") - val res1 = lines(4).contains("Added") && lines(4).contains("test1.jar") - val res2 = lines(lines.length-3).contains("test1.jar") && lines(lines.length-3).contains("existing classpath entries conflict") + assert { + lines(4).contains("Added") && lines(4).contains("test1.jar") + } + assert { + lines(lines.length-3).contains("test1.jar") && lines(lines.length-3).contains("existing classpath entries conflict") + } + } - println(s"test4 res1: $res1") - println(s"test4 res2: $res2") + def test5(): Unit = { + val codeToRun = ":require /does/not/exist.jar" + val output = ILoop.run(codeToRun, settings) + assert(!output.contains("NullPointerException"), output) + assert(output.contains("Cannot load '/does/not/exist.jar'"), output) + } + + def test6(): Unit = { + // Avoid java.lang.NoClassDefFoundError triggered by the old appoach of using a Java + // classloader to parse .class files in order to read their names. + val jar = "test6.jar" + compileCode(app6, jar) + val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar", "import test6._; new A; new Z") + val output = ILoop.run(codeToRun, settings) + assert(output.contains("created test6.A"), output) + assert(output.contains("created test6.Z"), output) } def show(): Unit = { @@ -110,7 +138,9 @@ object Test extends StoreReporterDirectTest { test2() test3() test4() + test5() + test6() } - def toCodeInSeparateLines(lines: String*): String = lines.map(_ + "\n").mkString + def toCodeInSeparateLines(lines: String*): String = lines mkString "\n" } diff --git a/test/files/scalacheck/nan-ordering.scala b/test/files/scalacheck/nan-ordering.scala index 2094a46e37..05e97a13c9 100644 --- a/test/files/scalacheck/nan-ordering.scala +++ b/test/files/scalacheck/nan-ordering.scala @@ -42,16 +42,16 @@ object Test extends Properties("NaN-Ordering") { property("Float equiv") = forAll(specFloats, specFloats) { (d1, d2) => numFloat.equiv(d1, d2) == (d1 == d2) } property("Float reverse.min") = forAll(specFloats, specFloats) { (d1, d2) => { - val mathmin = math.min(d1, d2) + val mathmax = math.max(d1, d2) val numericmin = numFloat.reverse.min(d1, d2) - mathmin == numericmin || mathmin.isNaN && numericmin.isNaN + mathmax == numericmin || mathmax.isNaN && numericmin.isNaN } } property("Float reverse.max") = forAll(specFloats, specFloats) { (d1, d2) => { - val mathmax = math.max(d1, d2) + val mathmin = math.min(d1, d2) val numericmax = numFloat.reverse.max(d1, d2) - mathmax == numericmax || mathmax.isNaN && numericmax.isNaN + mathmin == numericmax || mathmin.isNaN && numericmax.isNaN } } @@ -105,16 +105,16 @@ object Test extends Properties("NaN-Ordering") { property("Double equiv") = forAll(specDoubles, specDoubles) { (d1, d2) => numDouble.equiv(d1, d2) == (d1 == d2) } property("Double reverse.min") = forAll(specDoubles, specDoubles) { (d1, d2) => { - val mathmin = math.min(d1, d2) + val mathmax = math.max(d1, d2) val numericmin = numDouble.reverse.min(d1, d2) - mathmin == numericmin || mathmin.isNaN && numericmin.isNaN + mathmax == numericmin || mathmax.isNaN && numericmin.isNaN } } property("Double reverse.max") = forAll(specDoubles, specDoubles) { (d1, d2) => { - val mathmax = math.max(d1, d2) + val mathmin = math.min(d1, d2) val numericmax = numDouble.reverse.max(d1, d2) - mathmax == numericmax || mathmax.isNaN && numericmax.isNaN + mathmin == numericmax || mathmin.isNaN && numericmax.isNaN } } |