Skip to content
This repository
Browse code

Expand pattern match position tests.

 - Adds tests for unapplySeq and unapply: Boolean.
   Both seem to be well positioned after the previous
   changes.
  • Loading branch information...
commit 601536136e6300cb8fef8f20b1f1e74cec033621 1 parent 286dced
Jason Zaugg authored December 12, 2012
61  test/files/run/t6288.check
... ...
@@ -1,8 +1,8 @@
1 1
 [[syntax trees at end of                    patmat]] // newSource1
2 2
 [7]package [7]<empty> {
3  
-  [7]object Case3 extends [13][105]scala.AnyRef {
4  
-    [105]def <init>(): [13]Case3.type = [105]{
5  
-      [105][105][105]Case3.super.<init>();
  3
+  [7]object Case3 extends [13][106]scala.AnyRef {
  4
+    [106]def <init>(): [13]Case3.type = [106]{
  5
+      [106][106][106]Case3.super.<init>();
6 6
       [13]()
7 7
     };
8 8
     [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 @@
25 25
         [64]x
26 26
       }
27 27
     }
  28
+  };
  29
+  [113]object Case4 extends [119][217]scala.AnyRef {
  30
+    [217]def <init>(): [119]Case4.type = [217]{
  31
+      [217][217][217]Case4.super.<init>();
  32
+      [119]()
  33
+    };
  34
+    [127]def unapplySeq([138]z: [141]<type: [141]scala.Any>): [127]Option[List[Int]] = [167]scala.None;
  35
+    [175]{
  36
+      [175]case <synthetic> val x1: [175]Any = [175]"";
  37
+      [175]case5()[195]{
  38
+        [195]<synthetic> val o7: [195]Option[List[Int]] = [195][195]Case4.unapplySeq([195]x1);
  39
+        [195]if ([195]o7.isEmpty.unary_!)
  40
+          [195]if ([195][195][195][195]o7.get.!=([195]null).&&([195][195][195][195]o7.get.lengthCompare([195]1).==([195]0)))
  41
+            [195]{
  42
+              [201]val nr: [201]Int = [201][201]o7.get.apply([201]0);
  43
+              [208][208]matchEnd4([208]())
  44
+            }
  45
+          else
  46
+            [195][195]case6()
  47
+        else
  48
+          [195][195]case6()
  49
+      };
  50
+      [175]case6(){
  51
+        [175][175]matchEnd4([175]throw [175][175][175]new [175]MatchError([175]x1))
  52
+      };
  53
+      [175]matchEnd4(x: [NoPosition]Unit){
  54
+        [175]x
  55
+      }
  56
+    }
  57
+  };
  58
+  [224]object Case5 extends [230][312]scala.AnyRef {
  59
+    [312]def <init>(): [230]Case5.type = [312]{
  60
+      [312][312][312]Case5.super.<init>();
  61
+      [230]()
  62
+    };
  63
+    [238]def unapply([246]z: [249]<type: [249]scala.Any>): [238]Boolean = [265]true;
  64
+    [273]{
  65
+      [273]case <synthetic> val x1: [273]Any = [273]"";
  66
+      [273]case5()[293]{
  67
+        [293]<synthetic> val o7: [293]Option[List[Int]] = [293][293]Case4.unapplySeq([293]x1);
  68
+        [293]if ([293]o7.isEmpty.unary_!)
  69
+          [293]if ([293][293][293][293]o7.get.!=([293]null).&&([293][293][293][293]o7.get.lengthCompare([293]0).==([195]0)))
  70
+            [304][304]matchEnd4([304]())
  71
+          else
  72
+            [293][293]case6()
  73
+        else
  74
+          [293][293]case6()
  75
+      };
  76
+      [273]case6(){
  77
+        [273][273]matchEnd4([273]throw [273][273][273]new [273]MatchError([273]x1))
  78
+      };
  79
+      [273]matchEnd4(x: [NoPosition]Unit){
  80
+        [273]x
  81
+      }
  82
+    }
28 83
   }
29 84
 }
30 85
 
32  test/files/run/t6288.scala
@@ -6,14 +6,30 @@ object Test extends DirectTest {
6 6
   override def extraSettings: String = "-usejavacp -Xprint:patmat -Xprint-pos -d " + testOutput.path
7 7
 
8 8
   override def code =
9  
-  """
10  
-  |object Case3 {
11  
-  |  def unapply(z: Any): Option[Int] = Some(-1)
12  
-  |
13  
-  |  "" match {
14  
-  |    case Case3(nr) => ()
15  
-  |  }
16  
-  |}""".stripMargin.trim
  9
+    """
  10
+      |object Case3 {
  11
+      |  def unapply(z: Any): Option[Int] = Some(-1)
  12
+      |
  13
+      |  "" match {
  14
+      |    case Case3(nr) => ()
  15
+      |  }
  16
+      |}
  17
+      |object Case4 {
  18
+      |  def unapplySeq(z: Any): Option[List[Int]] = None
  19
+      |
  20
+      |  "" match {
  21
+      |    case Case4(nr) => ()
  22
+      |  }
  23
+      |}
  24
+      |object Case5 {
  25
+      |  def unapply(z: Any): Boolean = true
  26
+      |
  27
+      |  "" match {
  28
+      |    case Case4() => ()
  29
+      |  }
  30
+      |}
  31
+      |
  32
+      |""".stripMargin.trim
17 33
 
18 34
   override def show(): Unit = {
19 35
     // Now: [84][84]Case3.unapply([84]x1);

0 notes on commit 6015361

Please sign in to comment.
Something went wrong with that request. Please try again.