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

Unexpected results #63

Open
pboling opened this issue May 3, 2019 · 1 comment
Open

Unexpected results #63

pboling opened this issue May 3, 2019 · 1 comment

Comments

@pboling
Copy link
Contributor

pboling commented May 3, 2019

a = {a:'car', b:['truck', 'plane'] }
b = {a:'bus', b:['truck', ' plan'] }

diff = HashDiff.diff(a, b) do |path, obj1, obj2|
  case path
  when 'b[*]'
    true
  end
end
=> [["~", "a", "car", "bus"], ["-", "b[1]", "plane"], ["+", "b[1]", " plan"]]

vs.

a = {a:'car', b:['truck', 'plane'] }
b = {a:'bus', b:['truck', ' plan'] }

diff = HashDiff.diff(a, b) do |path, obj1, obj2|
  case path
  when 'b[*]'
    false
  end
end
=> [["~", "a", "car", "bus"], ["-", "b[1]", "plane"], ["+", "b[1]", " plan"]]

vs.

a = {a:'car', b:['truck', 'plane'] }
b = {a:'bus', b:['truck', ' plan'] }

diff = HashDiff.diff(a, b) do |path, obj1, obj2|
  case path
  when 'b[*]'
    raise "#{obj1} == #{obj2}"
  end
end
=> [["~", "a", "car", "bus"], ["-", "b[1]", "plane"], ["+", "b[1]", " plan"]]

It doesn't seem to make any difference what goes in the block as a custom comparator.

Also, when I do a puts inside the block to try and figure out what is going on there is no output?!

The raise is silently rescued?!

@krzysiek1507
Copy link
Collaborator

Hi @pboling Could you please check if it works on master branch? It's been fixed but not released yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants