Jruby: JRuby 9.2 Time to Date conversion bug ?

Created on 21 Sep 2018  路  5Comments  路  Source: jruby/jruby

Environment

JRuby 9.2.0.0
Linux

Expected Behavior

In this lib https://github.com/craiglittle/clavius, there's a test testing that a Time is well converted to the corresponding Date.
While this test passes for MRI Ruby 2.2.10, 2.3.7, 2.4.4, 2.5.1 and for JRuby 9.1.17.0, it fails for JRuby 9.2.0.0

I created a PR showing the problem here: https://github.com/guizmaii/clavius/pull/1
Travis tests are here: https://travis-ci.org/guizmaii/clavius/builds/431451640

Here's the error message:

       expected: #<Set: {#<Date: 2015-01-01 ((2457024j,0s,0n),+0s,2299161j)>, #<Date: 2015-01-02 ((2457025j,0s,0n),+0s,2299161j)>}>
            got: #<Set: {#<Date: 2015-01-01 ((2457024j,0s,0n),+0s,2299161j)>, #<Date: 2015-01-02 ((2457025j,0s,0n),+0s,0j)>}>

All 5 comments

any chance you good extract a simple reproducer for us?

simplified reproducer

require 'date'
require 'time'
Time.new(2015, 1, 2).to_date.inspect == Date.new(2015, 1, 2).inspect

@ahorek Thanks :)

thx, its been a while since 9.2.0 and this one got already reported, so its a known and fixed issue:

kares@clevo:~/workspace/oss/jruby$ bin/jruby -v -e "require 'date'; p Time.new(2015, 1, 2).to_date.inspect == Date.new(2015, 1, 2).inspect"
jruby 9.2.1.0-SNAPSHOT (2.5.0) 2018-09-11 055a178 Java HotSpot(TM) 64-Bit Server VM 10.0.1+10 on 10.0.1+10 +jit [linux-x86_64]
true

... there's a way to test against master even if you do not want to build yourself, just use jruby-head e.g. on Travis or with rvm install jruby-head

here's (likely) the same bug: https://github.com/jruby/jruby/issues/5279
... the regression in 9.2 is due a rewrite of date.rb into native (MRI did it several releases back)

Was this page helpful?
0 / 5 - 0 ratings