Comparing non-matching Floats gives `undefined method []' for 0.0:Float` within SuperDiff
simonrentzke opened this issue · 1 comments
simonrentzke commented
Hi, I've noticed some weird behaviour when floats are compared and they do not match
Example code:
require "rails_helper"
describe "BadMatcher", type: :feature do
it "should not give NoMethodError" do
expect(0.0).to eq(0.15)
end
end
Stack trace looks like this:
Failures:
1) BadMatcher should not give NoMethodError
Failure/Error: expect(0.0).to eq(0.15)
NoMethodError:
undefined method `[]' for 0.0:Float
# /Users/xxx/.gem/ruby/3.0.1/gems/super_diff-0.8.0/lib/super_diff/helpers.rb:55:in `object_address_for'
# /Users/xxx/.gem/ruby/3.0.1/gems/super_diff-0.8.0/lib/super_diff/operation_tree_flatteners/default_object.rb:8:in `open_token'
# /Users/xxx/.gem/ruby/3.0.1/gems/super_diff-0.8.0/lib/super_diff/operation_tree_flatteners/collection.rb:11:in `build_tiered_lines'
# /Users/xxx/.gem/ruby/3.0.1/gems/super_diff-0.8.0/lib/super_diff/operation_tree_flatteners/base.rb:50:in `tiered_lines'
# /Users/xxx/.gem/ruby/3.0.1/gems/super_diff-0.8.0/lib/super_diff/operation_tree_flatteners/base.rb:22:in `beginning_lines'
# /Users/xxx/.gem/ruby/3.0.1/gems/super_diff-0.8.0/lib/super_diff/operation_tree_flatteners/base.rb:10:in `call'
# /Users/xxx/.gem/ruby/3.0.1/gems/attr_extras-6.2.5/lib/attr_extras/explicit.rb:67:in `public_send'
# /Users/xxx/.gem/ruby/3.0.1/gems/attr_extras-6.2.5/lib/attr_extras/explicit.rb:67:in `block (2 levels) in static_facade'
# /Users/xxx/.gem/ruby/3.0.1/gems/super_diff-0.8.0/lib/super_diff/operation_trees/base.rb:28:in `flatten'
# /Users/xxx/.gem/ruby/3.0.1/gems/super_diff-0.8.0/lib/super_diff/operation_trees/base.rb:23:in `to_diff'
# /Users/xxx/.gem/ruby/3.0.1/gems/super_diff-0.8.0/lib/super_diff/differs/base.rb:15:in `call'
# /Users/xxx/.gem/ruby/3.0.1/gems/attr_extras-6.2.5/lib/attr_extras/explicit.rb:67:in `public_send'
# /Users/xxx/.gem/ruby/3.0.1/gems/attr_extras-6.2.5/lib/attr_extras/explicit.rb:67:in `block (2 levels) in static_facade'
# /Users/xxx/.gem/ruby/3.0.1/gems/super_diff-0.8.0/lib/super_diff/differs/main.rb:17:in `call'
# /Users/xxx/.gem/ruby/3.0.1/gems/attr_extras-6.2.5/lib/attr_extras/explicit.rb:67:in `public_send'
# /Users/xxx/.gem/ruby/3.0.1/gems/attr_extras-6.2.5/lib/attr_extras/explicit.rb:67:in `block (2 levels) in static_facade'
# /Users/xxx/.gem/ruby/3.0.1/gems/super_diff-0.8.0/lib/super_diff/rspec/differ.rb:10:in `diff'
# /Users/xxx/.gem/ruby/3.0.1/gems/attr_extras-6.2.5/lib/attr_extras/explicit.rb:73:in `public_send'
# /Users/xxx/.gem/ruby/3.0.1/gems/attr_extras-6.2.5/lib/attr_extras/explicit.rb:73:in `block (2 levels) in static_facade'
# /Users/xxx/.gem/ruby/3.0.1/gems/super_diff-0.8.0/lib/super_diff/rspec/monkey_patches.rb:345:in `block in diffs'
# /Users/xxx/.gem/ruby/3.0.1/gems/super_diff-0.8.0/lib/super_diff/rspec/monkey_patches.rb:344:in `map'
# /Users/xxx/.gem/ruby/3.0.1/gems/super_diff-0.8.0/lib/super_diff/rspec/monkey_patches.rb:344:in `diffs'
# /Users/xxx/.gem/ruby/3.0.1/gems/super_diff-0.8.0/lib/super_diff/rspec/monkey_patches.rb:331:in `message_with_diff'
# /Users/xxx/.gem/ruby/3.0.1/gems/super_diff-0.8.0/lib/super_diff/rspec/monkey_patches.rb:43:in `handle_failure'
# ./spec/example/bad_matcher_spec.rb:7:in `block (2 levels) in <top (required)>'
Thanks!
simonrentzke commented
ah, apologies, this looks like a duplicate of #136