String does not use <=> to compare two string instances
-------------------------------------------------------
Key: JRUBY-3925
URL: http://jira.codehaus.org/browse/JRUBY-3925
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.3.1
Environment: JRuby 1.3.1, java.runtime.version 1.6.0_13-b03-211, Mac
OS-X 10.5.8
Reporter: Jonathan Simms
Priority: Minor
Attachments: comparable-string-subclass.rb, jruby-1.3.1.out,
ruby-1.8.7p72.out
There seems to be different behavior between JRuby 1.3.1 and MRI Ruby 1.8.7p72
when it comes to String comparison. MRI uses the <=> operator, whereas JRuby
does not. This became an issue when I was trying to write a class that acted as
an Enum type (for use with rails backed by postgres). The class was a subclass
of String that overrode <=> to perform the comparison using an internal array
containing the Enum values rather than the value of the Strings themselves. I
was a bit surprised when my tests passed under ruby, but failed under jruby.
I've included a small test program and the output of both JRuby 1.3.1 and Ruby
1.8.7p72 (unfortunately, it isn't a junit test case, my apologies)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email