Add a test case for sorted attributes
1 files changed, 9 insertions(+), 2 deletions(-)

M test/core_test.rb
M test/core_test.rb +9 -2
@@ 95,12 95,19 @@ class Tester < Test::Unit::TestCase
     assert_equal text, value.to_s
 
     e = Element.new "test"
-    e.add_attributes({ "name1" => "test1", "name2" => "test2" })
-    e.add_attributes([["name3","test3"], ["name4","test4"]])
+    e.add_attributes({ "name1" => "test1", "name4" => "test4" })
+    e.add_attributes([["name3","test3"], ["name2","test2"]])
     assert_equal "test1", e.attributes["name1"]
     assert_equal "test2", e.attributes["name2"]
     assert_equal "test3", e.attributes["name3"]
     assert_equal "test4", e.attributes["name4"]
+
+    # ensure that the attributes come out in sorted order
+    assert_equal %w(<test
+      name1='test1'
+      name2='test2'
+      name3='test3'
+      name4='test4'/>).join(' '), e.to_s
   end
 
   def test_cdata