Skip to content

Conversation

@no-reply
Copy link
Member

@no-reply no-reply commented Jun 29, 2016

Ruby 2.3.0 changed the behavior of Comparable#== to avoid hiding errors. This led to NoMethodErrors for comparisons that return false for previous Rubies.

This introduces a custom RDF::List#== implementation for explicitly supported comparisons between RDF::Value classes. We return false immediately for RDF::Values which are not #list?; falling back on Comparable for other types.

Further, RDF::Lists with three elements that happen to coincide with the terms of an RDF::Statement would previously return true. E.g.: RDF::List[:s, :p, :o] == RDF::Statement(:s, :p, :o). This unusual edge case is patched by way of the changes described above.

A similar change is made to RDF::Statement#== to preserve symmetry.

Closes #304

Tom Johnson added 2 commits June 29, 2016 15:26
Ruby 2.3.0 changed the behavior of
[`Comparable#==`](https://bugs.ruby-lang.org/issues/7688) to avoid
hiding errors. This led to `NoMethodError`s for comparisons that return
`false` for previous Rubies.

This introduces a custom `RDF::List#==` implementation for explicitly
supported comparisons between `RDF::Value` classes. We return `false`
immediately for `RDF::Value`s which are not `#list?`; falling back on
`Comparable` for other types.

Further, `RDF::List`s with three elements that happen to coincide with
the terms of an RDF::Statement would previously return `true`. E.g.:
`RDF::List[:s, :p, :o] == RDF::Statement(:s, :p, :o)`. This unusual edge
case is patched by way of the changes described above.

Closes #304
Similar to the change for #304, an `RDF::List` containing the terms of a
Statement was evaluated as equal by `Statement#==`. This makes a change
to preserve symmetry of the `#==` relation.
@coveralls
Copy link

coveralls commented Jun 29, 2016

Coverage Status

Coverage increased (+0.006%) to 90.961% when pulling 9bd9cad on feature/list-value-eq into e990ded on develop.

@gkellogg gkellogg merged commit 378a369 into develop Jun 29, 2016
@gkellogg gkellogg deleted the feature/list-value-eq branch June 29, 2016 23:16
no-reply pushed a commit that referenced this pull request Jun 30, 2016
Using `Array(other)` instead of `other.to_a` avoids throwing errors when
comparing. This minor tweak slightly improves the solution to #304 given
in #305.
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

Successfully merging this pull request may close these issues.

4 participants