splitwise/super_diff

A failing spec with expect(value).to eq 1.0 raises JSON::ParserError

maxnotarangelo opened this issue · 5 comments

I'm getting a JSON::ParserError with the following code:

it "lets you compare a big float with another float" do
  expect(100_000.1).to eq 1.0
end

It looks like it's happening only when both numbers are floats, and the first is at least 100,000. The error is happening here: https://github.com/mcmire/super_diff/blob/d0ccdf204a54da14bfecdbb306008527c52f1686/lib/super_diff/helpers.rb#L55

The proximate cause is that

ObjectSpace.dump(100_000.1)
=> "100000."

I think this is a similar issue to #144.

Hi @maxnotarangelo, thanks for the report, makes sense to me. I'll have to think about how best to fix this as I sense it may be a tricky one although I'm not sure.

Hi @maxnotarangelo, just re-reviewing the issues list and ran across this issue. A fix for #144 was shipped in 0.9.0. Not sure if you still use the gem, but does that fix this issue for you?

Hmm, I'm already on 0.9.0 and I'm still getting the same error.