Skip to content

Commit

Permalink
Add missing support to Some equality
Browse files Browse the repository at this point in the history
  • Loading branch information
Seelengrab committed Dec 7, 2023
1 parent 4b05321 commit c122e73
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/some.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,5 @@ macro something(args...)
end

==(a::Some, b::Some) = a.value == b.value
isequal(a::Some, b::Some) = isequal(a.value, b.value)
hash(s::Some, h::UInt) = hash(s.value, hash(Some, h))
6 changes: 6 additions & 0 deletions test/some.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@

# Two Somes forward to their wrapped things

Check warning on line 56 in test/some.jl

View workflow job for this annotation

GitHub Actions / Check for new typos

perhaps "Somes" should be "Some or Sums".
@test ==(Some([0x1]), Some([1]))
@test ==(Some(1), missing) isa Missing
@test ==(missing, Some(1)) isa Missing
@test isequal(Some([0x1]), Some([1]))
@test !isequal(Some(missing), Some([1]))
@test !isequal(Some(1), Some(missing))
@test isequal(Some(missing), Some(missing))

# hashing implications
@test hash(Some(0x1)) != hash(0x1)
Expand Down

0 comments on commit c122e73

Please sign in to comment.