diff options
author | Heather Miller <heather.miller@epfl.ch> | 2012-08-07 18:36:36 +0200 |
---|---|---|
committer | Heather Miller <heather.miller@epfl.ch> | 2012-08-07 18:36:36 +0200 |
commit | ea81ab3314359c98986e6fac74c807fa1accdfb6 (patch) | |
tree | d39d7d549e765af105e1c0808808a8ea5d340037 /test/files/jvm | |
parent | 505cc713ec4546c5f9be1065e5fa3f7065451b8f (diff) | |
download | scala-ea81ab3314359c98986e6fac74c807fa1accdfb6.tar.gz scala-ea81ab3314359c98986e6fac74c807fa1accdfb6.tar.bz2 scala-ea81ab3314359c98986e6fac74c807fa1accdfb6.zip |
Added tests, removal of unnecessary methods, fixes prepare
Diffstat (limited to 'test/files/jvm')
-rw-r--r-- | test/files/jvm/future-spec/TryTests.scala | 12 | ||||
-rw-r--r-- | test/files/jvm/try-type-tests.scala | 14 |
2 files changed, 20 insertions, 6 deletions
diff --git a/test/files/jvm/future-spec/TryTests.scala b/test/files/jvm/future-spec/TryTests.scala index 47ce9c2e15..db0be0dfff 100644 --- a/test/files/jvm/future-spec/TryTests.scala +++ b/test/files/jvm/future-spec/TryTests.scala @@ -1,4 +1,4 @@ - +x // This is a port of the com.twitter.util Try spec. // -- // It lives in the future-spec directory simply because it requires a specs-like @@ -55,12 +55,12 @@ object TryTests extends MinimalScalaTest { Failure[Int](e) flatMap(x => Success(1 + x)) mustEqual Failure(e) } - // "when there is an exception" in { - // Success(1).flatMap[Int](_ => throw e) mustEqual Failure(e) + "when there is an exception" in { + Success(1).flatMap[Int](_ => throw e) mustEqual Failure(e) - // val e2 = new Exception - // Failure[Int](e).flatMap[Int](_ => throw e2) mustEqual Failure(e) - // } + val e2 = new Exception + Failure[Int](e).flatMap[Int](_ => throw e2) mustEqual Failure(e) + } } "flatten" in { diff --git a/test/files/jvm/try-type-tests.scala b/test/files/jvm/try-type-tests.scala index 9dece8d6d8..351f02b183 100644 --- a/test/files/jvm/try-type-tests.scala +++ b/test/files/jvm/try-type-tests.scala @@ -103,6 +103,20 @@ trait TryStandard { } } + 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 == s.get) + } + + 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() |