@@ -369,6 +369,14 @@ Ours is the portal of hope, come as you are."
369369 </wsdl:definitions>""" , wsdlTemplate4(" service4" , () => " target4" ) toString)
370370 }
371371
372+ @ UnitTest
373+ def t547 : Unit = {
374+ // ambiguous toString problem from #547
375+
376+ val atom : scala.xml.Atom [Unit ] = new scala.xml.Atom (())
377+ assertEquals(" ()" , atom.toString)
378+ }
379+
372380 @ UnitTest
373381 def t1079 = assertFalse(<t user : tag =" " /> == <t user : tag =" X" />)
374382
@@ -416,6 +424,30 @@ Ours is the portal of hope, come as you are."
416424 assertTrue(<k a =" 1" b =" 2" /> != <k b =" 2" />)
417425 }
418426
427+ @ UnitTest
428+ def t4124 : Unit = {
429+ val body : Node = <elem >hi</elem >
430+ assertEquals(" hi" , ((body : AnyRef , " foo" ): @ unchecked) match {
431+ case (node : Node , " bar" ) => " bye"
432+ case (ser : Serializable , " foo" ) => " hi"
433+ })
434+
435+ assertEquals(" hi" , ((body, " foo" ): @ unchecked) match {
436+ case (node : Node , " bar" ) => " bye"
437+ case (ser : Serializable , " foo" ) => " hi"
438+ })
439+
440+ assertEquals(" bye" , ((body : AnyRef , " foo" ): @ unchecked) match {
441+ case (node : Node , " foo" ) => " bye"
442+ case (ser : Serializable , " foo" ) => " hi"
443+ })
444+
445+ assertEquals(" bye" , ((body : AnyRef , " foo" ): @ unchecked) match {
446+ case (node : Node , " foo" ) => " bye"
447+ case (ser : Serializable , " foo" ) => " hi"
448+ })
449+ }
450+
419451 @ UnitTest
420452 def t5052 : Unit = {
421453 assertTrue(<elem attr ={ null : String }/> xml_== <elem />)
@@ -438,6 +470,19 @@ Ours is the portal of hope, come as you are."
438470 assertHonorsIterableContract(<a a =" " y ={ null : String }/>.attributes)
439471 }
440472
473+ @ UnitTest
474+ def t5154 : Unit = {
475+
476+ // extra space made the pattern OK
477+ def f = <z > {{3 }}</z > match { case <z > {{3 }}</z > => true }
478+
479+ // lack of space used to error: illegal start of simple pattern
480+ def g = <z >{{3 }}</z > match { case <z >{{3 }}</z > => true }
481+
482+ assertTrue(f)
483+ assertTrue(g)
484+ }
485+
441486 @ UnitTest
442487 def t5843 : Unit = {
443488 val foo = scala.xml.Attribute (null , " foo" , " 1" , scala.xml.Null )
@@ -468,6 +513,115 @@ Ours is the portal of hope, come as you are."
468513 assertEquals(""" <a a:b="1" a:c="2" a:d="3" a:e="4" a:f="5"/>""" , sort(<a a : b =" 1" a : c =" 2" a : d =" 3" a : e =" 4" a : f =" 5" />) toString)
469514 }
470515
516+ @ UnitTest
517+ def t8253 : Unit = {
518+ // `identity(foo)` used to match the overly permissive match in SymbolXMLBuilder
519+ // which was intended to more specifically match `_root_.scala.xml.Text(...)`
520+
521+ import reflect .runtime .universe ._ // not using the XML library in compiler tests
522+
523+ val ns1 = " ns1"
524+ assertEquals(reify(ns1).tree.toString, q " ns1 " .toString)
525+ assertEquals(" <sample xmlns='ns1'/>" ,
526+ """ |{
527+ | var $tmpscope: _root_.scala.xml.NamespaceBinding = $scope;
528+ | $tmpscope = new _root_.scala.xml.NamespaceBinding(null, "ns1", $tmpscope);
529+ | {
530+ | val $scope: _root_.scala.xml.NamespaceBinding = $tmpscope;
531+ | new _root_.scala.xml.Elem(null, "sample", _root_.scala.xml.Null, $scope, true)
532+ | }
533+ |}""" .stripMargin,
534+ q " <sample xmlns='ns1'/> " .toString)
535+ assertEquals(" <sample xmlns={identity(ns1)}/>" ,
536+ """ |{
537+ | var $tmpscope: _root_.scala.xml.NamespaceBinding = $scope;
538+ | $tmpscope = new _root_.scala.xml.NamespaceBinding(null, ns1, $tmpscope);
539+ | {
540+ | val $scope: _root_.scala.xml.NamespaceBinding = $tmpscope;
541+ | new _root_.scala.xml.Elem(null, "sample", _root_.scala.xml.Null, $scope, true)
542+ | }
543+ |}""" .stripMargin,
544+ q " <sample xmlns={ns1}/> " .toString)
545+ assertEquals(" <sample xmlns:foo='ns1'/>" ,
546+ """ |{
547+ | var $tmpscope: _root_.scala.xml.NamespaceBinding = $scope;
548+ | $tmpscope = new _root_.scala.xml.NamespaceBinding("foo", "ns1", $tmpscope);
549+ | {
550+ | val $scope: _root_.scala.xml.NamespaceBinding = $tmpscope;
551+ | new _root_.scala.xml.Elem(null, "sample", _root_.scala.xml.Null, $scope, true)
552+ | }
553+ |}""" .stripMargin,
554+ q " <sample xmlns:foo='ns1'/> " .toString)
555+ assertEquals(" <sample xmlns:foo={identity(ns1)}/>" ,
556+ """ |{
557+ | var $tmpscope: _root_.scala.xml.NamespaceBinding = $scope;
558+ | $tmpscope = new _root_.scala.xml.NamespaceBinding("foo", ns1, $tmpscope);
559+ | {
560+ | val $scope: _root_.scala.xml.NamespaceBinding = $tmpscope;
561+ | new _root_.scala.xml.Elem(null, "sample", _root_.scala.xml.Null, $scope, true)
562+ | }
563+ |}""" .stripMargin,
564+ q " <sample xmlns:foo={ns1}/> " .toString)
565+ }
566+
567+ @ UnitTest
568+ def t8466lift : Unit = {
569+ import scala .reflect .runtime .universe ._
570+
571+ implicit val liftXmlComment = Liftable [Comment ] { comment =>
572+ q " new _root_.scala.xml.Comment( ${comment.commentText}) "
573+ }
574+ liftXmlComment(Comment (" foo" ))
575+ assertEquals(q " ${Comment (" foo" )}" , q " <!--foo--> " )
576+ }
577+
578+ @ UnitTest
579+ def t8466unlift : Unit = {
580+ import scala .reflect .runtime .universe ._
581+
582+ implicit val unliftXmlComment = Unliftable [Comment ] {
583+ case q " new _root_.scala.xml.Comment( ${value : String }) " => Comment (value)
584+ }
585+ unliftXmlComment.unapply(q " <!--foo--> " )
586+ val q " ${comment : Comment }" = q " <!--foo--> "
587+ assertEquals(comment.commentText, " foo" )
588+ }
589+
590+ @ UnitTest
591+ def t9027 : Unit = {
592+ // used to be parsed as .println
593+
594+ import reflect .runtime ._ , universe ._
595+
596+ assertEquals(
597+ """ |{
598+ | {
599+ | val $buf = new _root_.scala.xml.NodeBuffer();
600+ | $buf.$amp$plus(new _root_.scala.xml.Elem(null, "a", _root_.scala.xml.Null, $scope, true));
601+ | $buf.$amp$plus(new _root_.scala.xml.Elem(null, "b", _root_.scala.xml.Null, $scope, true));
602+ | $buf
603+ | };
604+ | println("hello, world.")
605+ |}""" .stripMargin,
606+ q """ <a/><b/>
607+ println("hello, world.") """ .toString)
608+ assertEquals(
609+ """ |{
610+ | {
611+ | val $buf = new _root_.scala.xml.NodeBuffer();
612+ | $buf.$amp$plus(new _root_.scala.xml.Elem(null, "a", _root_.scala.xml.Null, $scope, true));
613+ | $buf.$amp$plus(new _root_.scala.xml.Elem(null, "b", _root_.scala.xml.Null, $scope, true));
614+ | $buf.$amp$plus(new _root_.scala.xml.Elem(null, "c", _root_.scala.xml.Null, $scope, true));
615+ | $buf
616+ | };
617+ | println("hello, world.")
618+ |}""" .stripMargin,
619+ q """ <a/>
620+ <b/>
621+ <c/>
622+ println("hello, world.") """ .toString)
623+ }
624+
471625 @ UnitTest
472626 def attributes = {
473627 val noAttr = <t />
0 commit comments