@@ -582,3 +582,34 @@ class ReplHighlightTests extends ReplTest(ReplTest.defaultOptions.filterNot(_.st
582
582
case class Tree(left: Tree, right: Tree)
583
583
def deepTree(depth: Int): Tree
584
584
deepTree(300)""" )
585
+
586
+ class ReplUnrollTests extends ReplTest (ReplTest .defaultOptions ++ Seq (" -experimental" , " -Xprint:pickler" )):
587
+ override val redirectOutput = true
588
+ @ Test def i23408 : Unit = initially :
589
+ run("""
590
+ import scala.annotation.unroll
591
+ case class Foo(x: Int, @unroll y: Option[String] = None)"""
592
+ )
593
+ val expected = List (
594
+ " def copy(x: Int, y: Option[String]): Foo = new Foo(x, y)" ,
595
+ " def copy(x: Int): Foo = this.copy(x, this.copy$default$2)" ,
596
+ " def copy$default$1: Int @uncheckedVariance = Foo.this.x" ,
597
+ " def copy$default$2: Option[String] @uncheckedVariance = Foo.this.y" ,
598
+ " def apply(x: Int, y: Option[String]): Foo = new Foo(x, y)" ,
599
+ " def apply(x: Int): Foo = this.apply(x, Foo.$lessinit$greater$default$2)" ,
600
+ """ def fromProduct(x$0: Product): Foo.MirroredMonoType = {
601
+ val arity: Int = x$0.productArity
602
+ val x$1: Int = x$0.productElement(0).$asInstanceOf[Int]
603
+ val y$1: Option[String] = (if arity > 1 then x$0.productElement(1) else Foo.$lessinit$greater$default$2).$asInstanceOf[Option[String]]
604
+ new Foo(x$1, y$1)
605
+ }"""
606
+ )
607
+ def trimWhitespaces (input : String ): String = input.replaceAll(" \\ s+" , " " )
608
+ val output = storedOutput()
609
+ val normalizedOutput = trimWhitespaces(output)
610
+ expected.foreach: defn =>
611
+ val normalizedDefn = trimWhitespaces(defn)
612
+ assertTrue(
613
+ s " Output: ' $output' did not contain expected definition: ${defn}" ,
614
+ normalizedOutput.contains(normalizedDefn)
615
+ )
0 commit comments