From ef536f00d9d480f28db3093b9dc09a90041cfb74 Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Thu, 25 Jun 2015 09:45:27 +0200 Subject: Enable 61 tests that succeed. --- tests/run/virtpatmat_try.scala | 47 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests/run/virtpatmat_try.scala (limited to 'tests/run/virtpatmat_try.scala') diff --git a/tests/run/virtpatmat_try.scala b/tests/run/virtpatmat_try.scala new file mode 100644 index 000000000..2cd05b799 --- /dev/null +++ b/tests/run/virtpatmat_try.scala @@ -0,0 +1,47 @@ +object Test extends dotty.runtime.LegacyApp { + case class A(val x: String) extends Throwable + class B extends Exception { override def toString = "B" } + def bla = 0 + + try { + throw new A("meh") + } catch { // this should emit a "catch-switch" + case y: A => println(y.x) + case (_ : A | _ : B) => println("B") + case _: Throwable => println("other") + } + + try { + throw new B() + } catch { // case classes and alternative flattening aren't supported yet, but could be in principle + // case A(x) => println(x) + case y: A => println(y.x) + case x@((_ : A) | (_ : B)) => println(x) + case _: Throwable => println("other") + } + + def simpleTry: Unit = { + try { + bla + } catch { + case x: Exception if x.getMessage == "test" => println("first case " + x) + case x: Exception => println("second case " + x) + } + } + + def typedWildcardTry: Unit = { + try { bla } catch { case _: ClassCastException => bla } + } + + def wildcardTry: Unit = { + try { bla } catch { case _: Throwable => bla } + } + + def tryPlusFinally: Unit = { + try { bla } finally { println("finally") } + } + + def catchAndPassToLambda: Unit = { + try { bla } catch { case ex: Exception => val f = () => ex } + } +} -- cgit v1.2.3