summaryrefslogtreecommitdiff
path: root/test/junit/scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@typesafe.com>2016-04-01 13:38:11 +0200
committerLukas Rytz <lukas.rytz@typesafe.com>2016-04-01 13:38:11 +0200
commitfe99c881edf127b9082fe15565ccfddb925f6fd4 (patch)
tree02c8401d758a9f2ab619bd981ead83215eac4cbd /test/junit/scala
parent96f230a0e9c254c45dc91c71b5929639e6add1f0 (diff)
parent20d262c0bb6615708ce95c399f9f842b4e93bb3c (diff)
downloadscala-fe99c881edf127b9082fe15565ccfddb925f6fd4.tar.gz
scala-fe99c881edf127b9082fe15565ccfddb925f6fd4.tar.bz2
scala-fe99c881edf127b9082fe15565ccfddb925f6fd4.zip
Merge pull request #5071 from janekdb/topic/2.12.x-scaladoc-Exceptions
Add initial unit test for Catch and augment documentation
Diffstat (limited to 'test/junit/scala')
-rw-r--r--test/junit/scala/util/control/ExceptionTest.scala42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/junit/scala/util/control/ExceptionTest.scala b/test/junit/scala/util/control/ExceptionTest.scala
new file mode 100644
index 0000000000..5211d31839
--- /dev/null
+++ b/test/junit/scala/util/control/ExceptionTest.scala
@@ -0,0 +1,42 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2016-2016, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+package scala.util
+
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.Test
+import org.junit.Assert._
+
+import scala.collection.mutable.ListBuffer
+
+import scala.util.control.Exception._
+
+@RunWith(classOf[JUnit4])
+class ExceptionTest {
+
+ @Test
+ def andFinally(): Unit = {
+
+ locally {
+ val audit = ListBuffer[Int]()
+ val katch = nonFatalCatch[Unit].andFinally(audit append 1)
+ val result = katch(10)
+ assertEquals(result, 10)
+ assertEquals(audit.toList, 1 :: Nil)
+ }
+
+ locally {
+ val audit = ListBuffer[Int]()
+ val katch = nonFatalCatch[Unit].andFinally(audit append 1).andFinally(audit append 2)
+ val result = katch(20)
+ assertEquals(result, 20)
+ assertEquals(audit.toList, 1 :: 2 :: Nil)
+ }
+ }
+} \ No newline at end of file