From 506a5e334d57084322fa89119d72fa96beb824b6 Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Mon, 15 Jun 2015 17:50:04 +0200 Subject: Enable tests that succeed. --- tests/run/lazy-exprs.scala | 95 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 tests/run/lazy-exprs.scala (limited to 'tests/run/lazy-exprs.scala') 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 "); 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 "); "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 "); "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 "); "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 +} -- cgit v1.2.3