aboutsummaryrefslogtreecommitdiff
path: root/tests/run/lazy-exprs.scala
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2015-06-15 17:50:04 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-06-15 17:50:04 +0200
commit506a5e334d57084322fa89119d72fa96beb824b6 (patch)
tree83401f75400ac373e5ae68d633bbf9de2b6ce8d9 /tests/run/lazy-exprs.scala
parentc4c29e393afb7175422053924b7e1e5a30131c4c (diff)
downloaddotty-506a5e334d57084322fa89119d72fa96beb824b6.tar.gz
dotty-506a5e334d57084322fa89119d72fa96beb824b6.tar.bz2
dotty-506a5e334d57084322fa89119d72fa96beb824b6.zip
Enable tests that succeed.
Diffstat (limited to 'tests/run/lazy-exprs.scala')
-rw-r--r--tests/run/lazy-exprs.scala95
1 files changed, 95 insertions, 0 deletions
diff --git a/tests/run/lazy-exprs.scala b/tests/run/lazy-exprs.scala
new file mode 100644
index 000000000..3ba6b46ab
--- /dev/null
+++ b/tests/run/lazy-exprs.scala
@@ -0,0 +1,95 @@
+object TestExpressions {
+
+ def patmatchScrut: Unit = {
+ lazy val z1: Option[String] = { println("forced <z1>"); Some("lazy z1") }
+
+ val res = z1 match {
+ case Some(msg) => msg
+ case None => "failed"
+ }
+ print("lazy val in scrutinee: ")
+ if (res == "lazy z1")
+ println("ok")
+ else
+ println("failed")
+ }
+
+ def patmatchCase: Unit = {
+ val t: Option[String] = Some("test")
+ val res = t match {
+ case Some(msg) =>
+ lazy val z1 = { println("forced <z1>"); "lazy z1" }
+ z1
+
+ case None => "failed"
+ }
+ print("lazy val in case: ")
+ if (res == "lazy z1")
+ println("ok")
+ else
+ println("failed")
+ }
+
+
+ def patmatchPat: Unit = {
+ lazy val Z1 = { println("forced <z1>"); "lazy Z1" }
+ print("lazy val in case: ")
+ val t: Option[String] = Some("lazy Z1")
+ t match {
+ case Some(Z1) =>
+ println("ok")
+
+ case None =>
+ println("failed")
+ }
+ }
+
+ def ifcond: Unit = {
+ lazy val z1 = { println("forced <z1>"); "lazy z1" }
+ print("lazy val in if condition: ")
+ if (z1 == "lazy z1")
+ println("ok")
+ else
+ println("failed")
+ }
+
+
+ lazy val LazyField = { println("forced LazyField"); "LazyField" }
+
+ def testPatMatchField: Unit = {
+ print("lazy val in pattern: ")
+ val t: Option[String] = Some("LazyField")
+ t match {
+ case Some(LazyField) =>
+ println("ok")
+
+ case None =>
+ println("failed")
+ }
+ }
+
+ lazy val (x, y) = ({print("x"); "x"}, {print("y"); "y"})
+ def testPatLazyVal: Unit = {
+ println("lazy val with patterns:")
+ print("x and y: ")
+ println("(" + x + ", " + y + ")")
+ lazy val (x1, y1) = ({print("x1"); "x1"}, {print("y1"); "y1"})
+ print("x1 and y1: ")
+ println("(" + x1 + ", " + y1 + ")")
+ }
+
+ def test: Unit = {
+ patmatchScrut
+ patmatchCase
+ patmatchPat
+ ifcond
+ testPatMatchField
+ testPatLazyVal
+ }
+}
+
+
+object Test extends dotty.runtime.LegacyApp {
+
+ TestExpressions.test
+}