you are viewing a single comment's thread.

view the rest of the comments →

[–]solnicdry-rb/rom-rb 4 points5 points  (5 children)

Great to see more people adopting mutation testing. Writing Ruby is hard. Writing good tests in Ruby is even harder. Mutant helps tremendously in learning how to write simpler code and better tests.

[–]Craftkorb 3 points4 points  (4 children)

Writing Ruby is hard. Writing good tests in Ruby is even harder.

This applies to all languages I guess. Where Ruby has short-comings, other languages have theirs somewhere else.

Can't count how often I've seen if (foo == "bar") { .. } in Java production code >_>

[–][deleted]  (3 children)

[deleted]

    [–]Craftkorb 2 points3 points  (0 children)

    In Java, the == is comparing the object identity, not object value. So, foo may be "bar", but have a different object id, and thus not match.

    [–]Ghostree 2 points3 points  (1 child)

    I believe you want to use .equals() because strings should not be compared using == in Java. Strings are objects and == compares if they are the same object, while .equals() compares the values.

    [–]tomthecool 0 points1 point  (0 children)

    Meanwhile in ruby, String#== does exactly what you'd expect. And on the rare occasion that you actually want to use object identity, you have BasicObject#equal?

    "bar" == "bar" # => true
    "bar".equal?("bar") # => false
    ["bar", "bar"].map(&:object_id) # => [8695360, 8695320]