diff options
author | Josh Suereth <Joshua.Suereth@gmail.com> | 2012-09-10 11:34:06 -0700 |
---|---|---|
committer | Josh Suereth <Joshua.Suereth@gmail.com> | 2012-09-10 11:34:06 -0700 |
commit | 782f362e0bcaa9609ed1a1c23c313257d0e22632 (patch) | |
tree | c1a78e864e91a67e454762274d46c796c6dcc56f /test/files | |
parent | 2ba98d18e216fbba378480ac6d790c5bea89f0b1 (diff) | |
parent | ed04e04a42010eccbe57fa6a6efa7a08334ca9ed (diff) | |
download | scala-782f362e0bcaa9609ed1a1c23c313257d0e22632.tar.gz scala-782f362e0bcaa9609ed1a1c23c313257d0e22632.tar.bz2 scala-782f362e0bcaa9609ed1a1c23c313257d0e22632.zip |
Merge pull request #1269 from jsuereth/wip/si-6333
Wip/si 6333
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/t6333.scala | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/files/run/t6333.scala b/test/files/run/t6333.scala new file mode 100644 index 0000000000..266d95ce69 --- /dev/null +++ b/test/files/run/t6333.scala @@ -0,0 +1,29 @@ +object Test extends App { + import util.Try + + val a = "apple" + def fail: String = throw new Exception("Fail!") + def argh: Try[String] = throw new Exception("Argh!") + + // No throw tests + def tryMethods(expr: => String): Unit = { + Try(expr) orElse argh + Try(expr).transform(_ => argh, _ => argh) + Try(expr).recoverWith { case e if (a == fail) => Try(a) } + Try(expr).recoverWith { case _ => argh } + Try(expr).getOrElse(a) + // TODO - Fail getOrElse? + Try(expr) orElse argh + Try(expr) orElse Try(a) + Try(expr) map (_ => fail) + Try(expr) map (_ => a) + Try(expr) flatMap (_ => argh) + Try(expr) flatMap (_ => Try(a)) + Try(expr) filter (_ => throw new Exception("O NOES")) + Try(expr) filter (_ => true) + Try(expr) recover { case _ => fail } + Try(expr).failed + } + tryMethods(a) + tryMethods(fail) +} |