diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2012-12-12 00:01:58 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2012-12-12 07:19:55 +0100 |
commit | 601536136e6300cb8fef8f20b1f1e74cec033621 (patch) | |
tree | 1167735759180e95103d1bd4045c1eeac5e589ca | |
parent | 286dced26e0d12796ab183b273ce6f00da182709 (diff) | |
download | scala-601536136e6300cb8fef8f20b1f1e74cec033621.tar.gz scala-601536136e6300cb8fef8f20b1f1e74cec033621.tar.bz2 scala-601536136e6300cb8fef8f20b1f1e74cec033621.zip |
Expand pattern match position tests.
- Adds tests for unapplySeq and unapply: Boolean.
Both seem to be well positioned after the previous
changes.
-rw-r--r-- | test/files/run/t6288.check | 61 | ||||
-rw-r--r-- | test/files/run/t6288.scala | 32 |
2 files changed, 82 insertions, 11 deletions
diff --git a/test/files/run/t6288.check b/test/files/run/t6288.check index e1aa58ea82..af6bd5d269 100644 --- a/test/files/run/t6288.check +++ b/test/files/run/t6288.check @@ -1,8 +1,8 @@ [[syntax trees at end of patmat]] // newSource1 [7]package [7]<empty> { - [7]object Case3 extends [13][105]scala.AnyRef { - [105]def <init>(): [13]Case3.type = [105]{ - [105][105][105]Case3.super.<init>(); + [7]object Case3 extends [13][106]scala.AnyRef { + [106]def <init>(): [13]Case3.type = [106]{ + [106][106][106]Case3.super.<init>(); [13]() }; [21]def unapply([29]z: [32]<type: [32]scala.Any>): [21]Option[Int] = [56][52][52]scala.Some.apply[[52]Int]([58]-1); @@ -25,6 +25,61 @@ [64]x } } + }; + [113]object Case4 extends [119][217]scala.AnyRef { + [217]def <init>(): [119]Case4.type = [217]{ + [217][217][217]Case4.super.<init>(); + [119]() + }; + [127]def unapplySeq([138]z: [141]<type: [141]scala.Any>): [127]Option[List[Int]] = [167]scala.None; + [175]{ + [175]case <synthetic> val x1: [175]Any = [175]""; + [175]case5()[195]{ + [195]<synthetic> val o7: [195]Option[List[Int]] = [195][195]Case4.unapplySeq([195]x1); + [195]if ([195]o7.isEmpty.unary_!) + [195]if ([195][195][195][195]o7.get.!=([195]null).&&([195][195][195][195]o7.get.lengthCompare([195]1).==([195]0))) + [195]{ + [201]val nr: [201]Int = [201][201]o7.get.apply([201]0); + [208][208]matchEnd4([208]()) + } + else + [195][195]case6() + else + [195][195]case6() + }; + [175]case6(){ + [175][175]matchEnd4([175]throw [175][175][175]new [175]MatchError([175]x1)) + }; + [175]matchEnd4(x: [NoPosition]Unit){ + [175]x + } + } + }; + [224]object Case5 extends [230][312]scala.AnyRef { + [312]def <init>(): [230]Case5.type = [312]{ + [312][312][312]Case5.super.<init>(); + [230]() + }; + [238]def unapply([246]z: [249]<type: [249]scala.Any>): [238]Boolean = [265]true; + [273]{ + [273]case <synthetic> val x1: [273]Any = [273]""; + [273]case5()[293]{ + [293]<synthetic> val o7: [293]Option[List[Int]] = [293][293]Case4.unapplySeq([293]x1); + [293]if ([293]o7.isEmpty.unary_!) + [293]if ([293][293][293][293]o7.get.!=([293]null).&&([293][293][293][293]o7.get.lengthCompare([293]0).==([195]0))) + [304][304]matchEnd4([304]()) + else + [293][293]case6() + else + [293][293]case6() + }; + [273]case6(){ + [273][273]matchEnd4([273]throw [273][273][273]new [273]MatchError([273]x1)) + }; + [273]matchEnd4(x: [NoPosition]Unit){ + [273]x + } + } } } diff --git a/test/files/run/t6288.scala b/test/files/run/t6288.scala index 9d8fb990d7..cf5865e95a 100644 --- a/test/files/run/t6288.scala +++ b/test/files/run/t6288.scala @@ -6,14 +6,30 @@ object Test extends DirectTest { override def extraSettings: String = "-usejavacp -Xprint:patmat -Xprint-pos -d " + testOutput.path override def code = - """ - |object Case3 { - | def unapply(z: Any): Option[Int] = Some(-1) - | - | "" match { - | case Case3(nr) => () - | } - |}""".stripMargin.trim + """ + |object Case3 { + | def unapply(z: Any): Option[Int] = Some(-1) + | + | "" match { + | case Case3(nr) => () + | } + |} + |object Case4 { + | def unapplySeq(z: Any): Option[List[Int]] = None + | + | "" match { + | case Case4(nr) => () + | } + |} + |object Case5 { + | def unapply(z: Any): Boolean = true + | + | "" match { + | case Case4() => () + | } + |} + | + |""".stripMargin.trim override def show(): Unit = { // Now: [84][84]Case3.unapply([84]x1); |