Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String does not use <=> to compare two string instances #2396

Closed
rjnienaber opened this issue Dec 30, 2014 · 3 comments
Closed

String does not use <=> to compare two string instances #2396

rjnienaber opened this issue Dec 30, 2014 · 3 comments

Comments

@rjnienaber
Copy link

From: http://jira.codehaus.org/browse/JRUBY-3925. Differs from MRI on JRuby 1.7.18 and JRuby 9000.

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)

@donv
Copy link
Member

donv commented Jan 3, 2015

Hi @rjnienaber !

Thanks for the report! JRuby 1.3.x is no longer supported. Could you try against JRuby 1.7.18?

Use the

--1.8

option to run in Ruby 1.8 mode.

@donv donv added the ruby 1.8 label Jan 3, 2015
@rjnienaber
Copy link
Author

Sorry that the ticket is unclear. This is an old ticket from the original JIRA issue tracker, JRUBY-3925. I tested it against JRuby 1.7.18 and JRuby 9000 and the behaviour is still the same as JRuby 1.3. The original ticket has 3 files with the output from the test.

jacknagel added a commit to Homebrew/install that referenced this issue Apr 17, 2015
@enebo enebo added this to the JRuby 9.2.0.0 milestone May 16, 2017
@enebo
Copy link
Member

enebo commented May 16, 2017

This was actually fixed some time during the 9.1.x cycle. I am marking against 9.2 so people can see it resolved. 1.7 is EOL so we won't be fixing it there.

@enebo enebo closed this as completed May 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants