diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/t6455.check | 4 | ||||
-rw-r--r-- | test/files/neg/t6455.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t6455.scala | 6 | ||||
-rw-r--r-- | test/files/pos/list-optim-check.flags | 1 | ||||
-rw-r--r-- | test/files/pos/list-optim-check.scala | 21 | ||||
-rw-r--r-- | test/files/run/t3235-minimal.check | 12 | ||||
-rw-r--r-- | test/files/run/t3235-minimal.flags | 1 | ||||
-rw-r--r-- | test/files/run/t3235-minimal.scala | 8 | ||||
-rw-r--r-- | test/files/run/t4288.scala | 2 | ||||
-rw-r--r-- | test/files/scalacheck/quasiquotes/TypecheckedProps.scala | 2 | ||||
-rw-r--r-- | test/junit/scala/util/TryTest.scala | 35 |
11 files changed, 91 insertions, 2 deletions
diff --git a/test/files/neg/t6455.check b/test/files/neg/t6455.check new file mode 100644 index 0000000000..8f2aad0b9e --- /dev/null +++ b/test/files/neg/t6455.check @@ -0,0 +1,4 @@ +t6455.scala:5: error: value withFilter is not a member of object O + O.withFilter(f => true) + ^ +one error found diff --git a/test/files/neg/t6455.flags b/test/files/neg/t6455.flags new file mode 100644 index 0000000000..112fc720a0 --- /dev/null +++ b/test/files/neg/t6455.flags @@ -0,0 +1 @@ +-Xfuture
\ No newline at end of file diff --git a/test/files/neg/t6455.scala b/test/files/neg/t6455.scala new file mode 100644 index 0000000000..ebbb37f1cd --- /dev/null +++ b/test/files/neg/t6455.scala @@ -0,0 +1,6 @@ +object O { def filter(p: Int => Boolean): O.type = this } + +class Test { + // should not compile because we no longer rewrite withFilter => filter under -Xfuture + O.withFilter(f => true) +}
\ No newline at end of file diff --git a/test/files/pos/list-optim-check.flags b/test/files/pos/list-optim-check.flags new file mode 100644 index 0000000000..49d036a887 --- /dev/null +++ b/test/files/pos/list-optim-check.flags @@ -0,0 +1 @@ +-optimize diff --git a/test/files/pos/list-optim-check.scala b/test/files/pos/list-optim-check.scala new file mode 100644 index 0000000000..f6e6ddec77 --- /dev/null +++ b/test/files/pos/list-optim-check.scala @@ -0,0 +1,21 @@ +// Tests a map known to crash in optimizer with faster List map in SI-8240. +// Equivalent tests for collect and flatmap do not crash, but are provided +// anyway. +// See ticket SI-8334 for optimizer bug. +// TODO - Remove this test once SI-8334 is fixed and has its own test. +class A { + def f: Boolean = { + val xs = Nil map (_ => return false) + true + } + + def g: Boolean = { + val xs = Nil collect { case _ => return false } + true + } + + def h: Boolean = { + val xs = Nil flatMap { _ => return false } + true + } +} diff --git a/test/files/run/t3235-minimal.check b/test/files/run/t3235-minimal.check new file mode 100644 index 0000000000..d7f716002f --- /dev/null +++ b/test/files/run/t3235-minimal.check @@ -0,0 +1,12 @@ +t3235-minimal.scala:3: warning: method round in class RichInt is deprecated: This is an integer type; there is no reason to round it. Perhaps you meant to call this on a floating-point value? + assert(123456789.round == 123456789) + ^ +t3235-minimal.scala:4: warning: method round in package math is deprecated: This is an integer type; there is no reason to round it. Perhaps you meant to call this with a floating-point value? + assert(math.round(123456789) == 123456789) + ^ +t3235-minimal.scala:5: warning: method round in class RichLong is deprecated: This is an integer type; there is no reason to round it. Perhaps you meant to call this on a floating-point value? + assert(1234567890123456789L.round == 1234567890123456789L) + ^ +t3235-minimal.scala:6: warning: method round in package math is deprecated: This is an integer type; there is no reason to round it. Perhaps you meant to call this with a floating-point value? + assert(math.round(1234567890123456789L) == 1234567890123456789L) + ^ diff --git a/test/files/run/t3235-minimal.flags b/test/files/run/t3235-minimal.flags new file mode 100644 index 0000000000..dcc59ebe32 --- /dev/null +++ b/test/files/run/t3235-minimal.flags @@ -0,0 +1 @@ +-deprecation diff --git a/test/files/run/t3235-minimal.scala b/test/files/run/t3235-minimal.scala new file mode 100644 index 0000000000..dc9907b63b --- /dev/null +++ b/test/files/run/t3235-minimal.scala @@ -0,0 +1,8 @@ +object Test { + def main(args: Array[String]) { + assert(123456789.round == 123456789) + assert(math.round(123456789) == 123456789) + assert(1234567890123456789L.round == 1234567890123456789L) + assert(math.round(1234567890123456789L) == 1234567890123456789L) + } +} diff --git a/test/files/run/t4288.scala b/test/files/run/t4288.scala index 4e7b366f60..23319d1c27 100644 --- a/test/files/run/t4288.scala +++ b/test/files/run/t4288.scala @@ -1,6 +1,6 @@ object Test { def f1 = scala.collection.mutable.ListBuffer(1 to 9: _*).slice(-5, -1) - def f2 = scala.collection.mutable.ListBuffer(1 to 9: _*).readOnly.slice(-5, -1) + def f2 = List(1 to 9: _*).slice(-5, -1) def f3 = Vector(1 to 9: _*).slice(-5, -1) def f4 = Traversable(1 to 9: _*).slice(-5, -1) def f5 = (1 to 9).toArray.slice(-5, -1) diff --git a/test/files/scalacheck/quasiquotes/TypecheckedProps.scala b/test/files/scalacheck/quasiquotes/TypecheckedProps.scala index 432c0959c9..7c4cb0306e 100644 --- a/test/files/scalacheck/quasiquotes/TypecheckedProps.scala +++ b/test/files/scalacheck/quasiquotes/TypecheckedProps.scala @@ -44,7 +44,7 @@ object TypecheckedProps extends QuasiquoteProperties("typechecked") { val enums = fq"foo <- new Foo" :: fq"if foo != null" :: Nil val body = q"foo" val q"$_; for(..$enums1) yield $body1" = typecheck(q""" - class Foo { def map(f: Any => Any) = this; def filter(cond: Any => Boolean) = this } + class Foo { def map(f: Any => Any) = this; def withFilter(cond: Any => Boolean) = this } for(..$enums) yield $body """) assert(enums1 ≈ enums) diff --git a/test/junit/scala/util/TryTest.scala b/test/junit/scala/util/TryTest.scala new file mode 100644 index 0000000000..03604a8065 --- /dev/null +++ b/test/junit/scala/util/TryTest.scala @@ -0,0 +1,35 @@ +package scala.util + +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 +import org.junit.Test +import org.junit.Assert._ + +/* Test Try's withFilter method, which was added along with the -Xfuture fix for SI-6455 */ +@RunWith(classOf[JUnit4]) +class TryTest { + @Test + def withFilterFail(): Unit = { + val fail = for (x <- util.Try(1) if x > 1) yield x + assert(fail.isFailure) + } + + @Test + def withFilterSuccess(): Unit = { + val success1 = for (x <- util.Try(1) if x >= 1) yield x + assertEquals(success1, util.Success(1)) + } + + @Test + def withFilterFlatMap(): Unit = { + val successFlatMap = for (x <- util.Try(1) if x >= 1; y <- util.Try(2) if x < y) yield x + assertEquals(successFlatMap, util.Success(1)) + } + + @Test + def withFilterForeach(): Unit = { + var ok = false + for (x <- util.Try(1) if x == 1) ok = x == 1 + assert(ok) + } +}
\ No newline at end of file |