diff options
author | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2013-02-25 15:08:28 -0800 |
---|---|---|
committer | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2013-02-25 15:08:28 -0800 |
commit | 3b85c3d22b9d62e9e07c53f235ae8e889581ddc8 (patch) | |
tree | d269d42c31fbcd9f39601772d36b9e63136ff717 | |
parent | 4cb1ee413a52f3fa1c85def20bf1143e8ef7d840 (diff) | |
parent | 8187debb7148483d991b7fa131e0c66cdee6e646 (diff) | |
download | scala-3b85c3d22b9d62e9e07c53f235ae8e889581ddc8.tar.gz scala-3b85c3d22b9d62e9e07c53f235ae8e889581ddc8.tar.bz2 scala-3b85c3d22b9d62e9e07c53f235ae8e889581ddc8.zip |
Merge pull request #2149 from khernyo/issue/7074
SI-7074 Fix xml attribute sorting
-rwxr-xr-x | src/library/scala/xml/Utility.scala | 2 | ||||
-rw-r--r-- | test/files/run/t7074.check | 9 | ||||
-rw-r--r-- | test/files/run/t7074.scala | 15 |
3 files changed, 25 insertions, 1 deletions
diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala index 9429e9caa7..030a89773e 100755 --- a/src/library/scala/xml/Utility.scala +++ b/src/library/scala/xml/Utility.scala @@ -64,7 +64,7 @@ object Utility extends AnyRef with parsing.TokenTests { val key = md.key val smaller = sort(md.filter { m => m.key < key }) val greater = sort(md.filter { m => m.key > key }) - smaller.copy(md.copy ( greater )) + smaller.foldRight (md copy greater) ((x, xs) => x copy xs) } /** Return the node with its attribute list sorted alphabetically diff --git a/test/files/run/t7074.check b/test/files/run/t7074.check new file mode 100644 index 0000000000..ab9cf11f16 --- /dev/null +++ b/test/files/run/t7074.check @@ -0,0 +1,9 @@ +<a/> +<a b="2" c="3" d="1"/> +<a b="2" c="4" d="1" e="3" f="5"/> +<a b="5" c="4" d="3" e="2" f="1"/> +<a b="1" c="2" d="3" e="4" f="5"/> +<a a:b="2" a:c="3" a:d="1"/> +<a a:b="2" a:c="4" a:d="1" a:e="3" a:f="5"/> +<a a:b="5" a:c="4" a:d="3" a:e="2" a:f="1"/> +<a a:b="1" a:c="2" a:d="3" a:e="4" a:f="5"/> diff --git a/test/files/run/t7074.scala b/test/files/run/t7074.scala new file mode 100644 index 0000000000..693a076a7a --- /dev/null +++ b/test/files/run/t7074.scala @@ -0,0 +1,15 @@ +import scala.xml.Utility.sort + +object Test extends App { + println(sort(<a/>)) + println(sort(<a d="1" b="2" c="3"/>)) + println(sort(<a d="1" b="2" e="3" c="4" f="5"/>)) + println(sort(<a f="1" e="2" d="3" c="4" b="5"/>)) + println(sort(<a b="1" c="2" d="3" e="4" f="5"/>)) + + println(sort(<a a:d="1" a:b="2" a:c="3"/>)) + println(sort(<a a:d="1" a:b="2" a:e="3" a:c="4" a:f="5"/>)) + println(sort(<a a:f="1" a:e="2" a:d="3" a:c="4" a:b="5"/>)) + println(sort(<a a:b="1" a:c="2" a:d="3" a:e="4" a:f="5"/>)) +} + |