summaryrefslogtreecommitdiff
path: root/test/junit
diff options
context:
space:
mode:
authorGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2014-02-25 13:50:19 +0100
committerGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2014-02-25 13:50:19 +0100
commit1ea43ffb2286d63e133839c1ea0b09449b0ac168 (patch)
tree2d003de0ec0e2687eaef214d65e46922b9e86264 /test/junit
parent7c709e122f7471353749525cff15602783fb348c (diff)
parent12dc4a28da8d3631734603c896d2ee1ba21b31d6 (diff)
downloadscala-1ea43ffb2286d63e133839c1ea0b09449b0ac168.tar.gz
scala-1ea43ffb2286d63e133839c1ea0b09449b0ac168.tar.bz2
scala-1ea43ffb2286d63e133839c1ea0b09449b0ac168.zip
Merge pull request #3566 from adriaanm/t6455
SI-6455 no longer rewrite .withFilter to .filter
Diffstat (limited to 'test/junit')
-rw-r--r--test/junit/scala/util/TryTest.scala35
1 files changed, 35 insertions, 0 deletions
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