My fault. The tests are bad.
Thanks!
Tomas
-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at
rubyforge.org] On Behalf Of Miguel de Icaza
Sent: Wednesday, November 07, 2007 1:47 PM
To: ironruby-core at rubyforge.org
Subject: [Ironruby-core] IronRuby and Dictionaries.
Hello John,
First the simple problem: I have been investigating some of the
failures in the IronRuby test suite while running on Mono. Some of the
problems in the tests depend on the order that Dictionary<>''s
GetEnumerator will return the data. But Dictionaries do not have any
sorting order specified. The order of the results is implementation
specific, and I bet they also depend on the number of elements in the
Dictionary as well as the hashcodes of the elements for the order.
A simple case of this problem is:
module M
C = 1
class D
end
end
M.constants.each { |x| puts x }
In this test, when you call M.constants.each sometimes we return
D,C and sometimes we return C,D. If the order is important, maybe the
code should switch to use SortedDictionary instead of using a plain
Dictionary?
The second problem is with Hash, some of the tests are failing on
Mono, again because the code assumes that code will be returned in
sorted order by the Dictionary, for example consider:
>>> puts ''Q'' => ''W'',
''E'' => ''R'', ''T'' =>
''Y''
In IronRuby/Mono this returns: TYERQW
In IronRuby/.NET this return: QWERTY
In Ruby this returns; QWERTY
But Ruby and IronRuby seem to disagree on another simple example:
>>> puts ''a'' => ''A'',
''A'' => ''a''
In IronRuby/.NET this return: aAAa
In irb this returns: AaaA
In IronRuby/Mono this returns: aAAa
The change here is a bit elaborate than just changing class Hash to
derive from SortedDictionary, it is also necessary to proxy this code to
RubyOps not to the existing Equal method, but to a Compare method that
can return an int to identify less, equal or bigger.
miguel
_______________________________________________
Ironruby-core mailing list
Ironruby-core at rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core