summaryrefslogtreecommitdiff
path: root/test/files/jvm/try-type-tests.scala
diff options
context:
space:
mode:
authorSimon Ochsenreither <simon@ochsenreither.de>2013-12-10 20:11:07 +0100
committerSimon Ochsenreither <simon@ochsenreither.de>2014-01-09 00:43:14 +0100
commitc5567e2700dfe6c19d968c2285821ef4ab8a8e6c (patch)
tree6a120e3ec4d31224fd3f36956824b1a23944dee7 /test/files/jvm/try-type-tests.scala
parentada8d9156baad2d8a24c1a40e032eb4bc7154bac (diff)
downloadscala-c5567e2700dfe6c19d968c2285821ef4ab8a8e6c.tar.gz
scala-c5567e2700dfe6c19d968c2285821ef4ab8a8e6c.tar.bz2
scala-c5567e2700dfe6c19d968c2285821ef4ab8a8e6c.zip
SI-8035 Deprecate automatic () insertion in argument lists
This promotes the () insertion warning from -Ywarn-adapted-args to a deprecation warning. -Xfuture tunrs it into a compiler error. Auto tupling remains unchanged for now. The tests have been fixed the following way: - Warnings caused by general sloppiness (Try(), Future(), ...) have been fixed. - Warnings which raise interesting questions (x == (), ...) received an updated checkfile for now.
Diffstat (limited to 'test/files/jvm/try-type-tests.scala')
-rw-r--r--test/files/jvm/try-type-tests.scala264
1 files changed, 132 insertions, 132 deletions
diff --git a/test/files/jvm/try-type-tests.scala b/test/files/jvm/try-type-tests.scala
index e5e53ee737..962afbd30f 100644
--- a/test/files/jvm/try-type-tests.scala
+++ b/test/files/jvm/try-type-tests.scala
@@ -3,139 +3,139 @@ import scala.util.{Try, Success, Failure}
// tests the basic combinators on Try
trait TryStandard {
- def testForeachSuccess(): Unit = {
- val t = Success(1)
- var res = 0
- t.foreach(x => res = x * 10)
- assert(res == 10)
- }
-
- def testForeachFailure(): Unit = {
- val t = Failure(new Exception("foo"))
- t.foreach(x => assert(false))
- }
-
- def testFlatMapSuccess(): Unit = {
- val t = Success(1)
- val n = t.flatMap(x => Try(x * 10))
- assert(n.get == 10)
- }
-
- def testFlatMapFailure(): Unit = {
- val t = Failure(new Exception("foo"))
- val n = t.flatMap{ x => assert(false); Try() }
- }
-
- def testMapSuccess(): Unit = {
- val t = Success(1)
- val n = t.map(x => x * 10)
- assert(n.get == 10)
- }
-
- def testMapFailure(): Unit = {
- val t = Failure(new Exception("foo"))
- val n = t.map(x => assert(false))
- }
-
- def testFilterSuccessTrue(): Unit = {
- val t = Success(1)
- val n = t.filter(x => x > 0)
- assert(n.get == 1)
- }
-
- def testFilterSuccessFalse(): Unit = {
- val t = Success(1)
- val n = t.filter(x => x < 0)
- n match {
- case Success(v) => assert(false)
- case Failure(e: NoSuchElementException) => assert(true)
+ def testForeachSuccess(): Unit = {
+ val t = Success(1)
+ var res = 0
+ t.foreach(x => res = x * 10)
+ assert(res == 10)
+ }
+
+ def testForeachFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ t.foreach(x => assert(false))
+ }
+
+ def testFlatMapSuccess(): Unit = {
+ val t = Success(1)
+ val n = t.flatMap(x => Try(x * 10))
+ assert(n.get == 10)
+ }
+
+ def testFlatMapFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ val n = t.flatMap{ x => assert(false); Try(()) }
+ }
+
+ def testMapSuccess(): Unit = {
+ val t = Success(1)
+ val n = t.map(x => x * 10)
+ assert(n.get == 10)
+ }
+
+ def testMapFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ val n = t.map(x => assert(false))
+ }
+
+ def testFilterSuccessTrue(): Unit = {
+ val t = Success(1)
+ val n = t.filter(x => x > 0)
+ assert(n.get == 1)
+ }
+
+ def testFilterSuccessFalse(): Unit = {
+ val t = Success(1)
+ val n = t.filter(x => x < 0)
+ n match {
+ case Success(v) => assert(false)
+ case Failure(e: NoSuchElementException) => assert(true)
case _ => assert(false)
- }
- }
-
- def testFilterFailure(): Unit = {
- val t = Failure(new Exception("foo"))
- val n = t.filter{ x => assert(false); true }
- }
-
- def testRescueSuccess(): Unit = {
- val t = Success(1)
- t.recoverWith{ case x => assert(false); Try() }
- }
-
- def testRescueFailure(): Unit = {
- val t = Failure(new Exception("foo"))
- val n = t.recoverWith{ case x => Try(1) }
- assert(n.get == 1)
- }
-
- def testRecoverSuccess(): Unit = {
- val t = Success(1)
- t.recover{ case x => assert(false); 99 }
- }
-
- def testRecoverFailure(): Unit = {
- val t = Failure(new Exception("foo"))
- val n = t.recover{ case x => 1 }
- assert(n.get == 1)
- }
-
- def testFlattenSuccess(): Unit = {
- val f = Failure(new Exception("foo"))
- val t = Success(f)
- assert(t.flatten == f)
- }
-
- def testFailedSuccess(): Unit = {
- val t = Success(1)
- val n = t.failed
- n match {
- case Failure(e: UnsupportedOperationException) => assert(true)
- case _ => assert(false)
- }
- }
-
- def testFailedFailure(): Unit = {
- val t = Failure(new Exception("foo"))
- val n = t.failed
- n match {
- case Success(e: Exception) => assert(true)
- case _ => assert(false)
- }
- }
-
- def testSuccessTransform(): Unit = {
- val s = Success(1)
- val succ = (x: Int) => Success(x * 10)
- val fail = (x: Throwable) => Success(0)
- assert(s.transform(succ, fail).get == 10)
- }
-
- def testFailureTransform(): Unit = {
- val f = Failure(new Exception("foo"))
- val succ = (x: Int) => Success(x * 10)
- val fail = (x: Throwable) => Success(0)
- assert(f.transform(succ, fail).get == 0)
- }
-
- testForeachSuccess()
- testForeachFailure()
- testFlatMapSuccess()
- testFlatMapFailure()
- testMapSuccess()
- testMapFailure()
- testFilterSuccessTrue()
- testFilterSuccessFalse()
- testFilterFailure()
- testRescueSuccess()
- testRescueFailure()
- testRecoverSuccess()
- testRecoverFailure()
- testFlattenSuccess()
- testFailedSuccess()
- testFailedFailure()
- testSuccessTransform()
- testFailureTransform()
+ }
+ }
+
+ def testFilterFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ val n = t.filter{ x => assert(false); true }
+ }
+
+ def testRescueSuccess(): Unit = {
+ val t = Success(1)
+ t.recoverWith{ case x => assert(false); Try(()) }
+ }
+
+ def testRescueFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ val n = t.recoverWith{ case x => Try(1) }
+ assert(n.get == 1)
+ }
+
+ def testRecoverSuccess(): Unit = {
+ val t = Success(1)
+ t.recover{ case x => assert(false); 99 }
+ }
+
+ def testRecoverFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ val n = t.recover{ case x => 1 }
+ assert(n.get == 1)
+ }
+
+ def testFlattenSuccess(): Unit = {
+ val f = Failure(new Exception("foo"))
+ val t = Success(f)
+ assert(t.flatten == f)
+ }
+
+ def testFailedSuccess(): Unit = {
+ val t = Success(1)
+ val n = t.failed
+ n match {
+ case Failure(e: UnsupportedOperationException) => assert(true)
+ case _ => assert(false)
+ }
+ }
+
+ def testFailedFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ val n = t.failed
+ n match {
+ case Success(e: Exception) => assert(true)
+ case _ => assert(false)
+ }
+ }
+
+ def testSuccessTransform(): Unit = {
+ val s = Success(1)
+ val succ = (x: Int) => Success(x * 10)
+ val fail = (x: Throwable) => Success(0)
+ assert(s.transform(succ, fail).get == 10)
+ }
+
+ def testFailureTransform(): Unit = {
+ val f = Failure(new Exception("foo"))
+ val succ = (x: Int) => Success(x * 10)
+ val fail = (x: Throwable) => Success(0)
+ assert(f.transform(succ, fail).get == 0)
+ }
+
+ testForeachSuccess()
+ testForeachFailure()
+ testFlatMapSuccess()
+ testFlatMapFailure()
+ testMapSuccess()
+ testMapFailure()
+ testFilterSuccessTrue()
+ testFilterSuccessFalse()
+ testFilterFailure()
+ testRescueSuccess()
+ testRescueFailure()
+ testRecoverSuccess()
+ testRecoverFailure()
+ testFlattenSuccess()
+ testFailedSuccess()
+ testFailedFailure()
+ testSuccessTransform()
+ testFailureTransform()
}
object Test