Skip to content

Commit

Permalink
Align method names with changes from #10020
Browse files Browse the repository at this point in the history
  • Loading branch information
Sija committed Jan 18, 2021
1 parent 81dc116 commit 465e548
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
48 changes: 24 additions & 24 deletions spec/std/hash_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -105,43 +105,43 @@ describe "Hash" do
h3 = {"c" => 3}
h4 = {} of Nil => Nil

describe "#proper_subset?" do
describe "#proper_subset_of?" do
it do
h1.proper_subset?(h2).should be_true
h2.proper_subset?(h1).should be_false
h1.proper_subset?(h1).should be_false
h1.proper_subset?(h3).should be_false
h1.proper_subset?(h4).should be_false
h1.proper_subset_of?(h2).should be_true
h2.proper_subset_of?(h1).should be_false
h1.proper_subset_of?(h1).should be_false
h1.proper_subset_of?(h3).should be_false
h1.proper_subset_of?(h4).should be_false
end
end

describe "#subset?" do
describe "#subset_of?" do
it do
h1.subset?(h2).should be_true
h2.subset?(h1).should be_false
h1.subset?(h1).should be_true
h1.subset?(h3).should be_false
h1.subset?(h4).should be_false
h1.subset_of?(h2).should be_true
h2.subset_of?(h1).should be_false
h1.subset_of?(h1).should be_true
h1.subset_of?(h3).should be_false
h1.subset_of?(h4).should be_false
end
end

describe "#proper_superset?" do
describe "#proper_superset_of?" do
it do
h1.proper_superset?(h2).should be_false
h2.proper_superset?(h1).should be_true
h1.proper_superset?(h1).should be_false
h1.proper_superset?(h3).should be_false
h1.proper_superset?(h4).should be_true
h1.proper_superset_of?(h2).should be_false
h2.proper_superset_of?(h1).should be_true
h1.proper_superset_of?(h1).should be_false
h1.proper_superset_of?(h3).should be_false
h1.proper_superset_of?(h4).should be_true
end
end

describe "#superset?" do
describe "#superset_of?" do
it do
h1.superset?(h2).should be_false
h2.superset?(h1).should be_true
h1.superset?(h1).should be_true
h1.superset?(h3).should be_false
h1.superset?(h4).should be_true
h1.superset_of?(h2).should be_false
h2.superset_of?(h1).should be_true
h1.superset_of?(h1).should be_true
h1.superset_of?(h3).should be_false
h1.superset_of?(h4).should be_true
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions src/hash.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1748,25 +1748,25 @@ class Hash(K, V)
end

# Returns `true` if `self` is a subset of *other*.
def proper_subset?(other : Hash)
def proper_subset_of?(other : Hash)
return false if other.size <= size
all? { |key, value| other[key]? == value }
end

# Returns `true` if `self` is a subset of *other* or equals to *other*.
def subset?(other : Hash)
def subset_of?(other : Hash)
return false if other.size < size
all? { |key, value| other[key]? == value }
end

# Returns `true` if *other* is a subset of `self`.
def superset?(other : Hash)
other.subset?(self)
def superset_of?(other : Hash)
other.subset_of?(self)
end

# Returns `true` if *other* is a subset of `self` or equals to `self`.
def proper_superset?(other : Hash)
other.proper_subset?(self)
def proper_superset_of?(other : Hash)
other.proper_subset_of?(self)
end

# See `Object#hash(hasher)`
Expand Down

0 comments on commit 465e548

Please sign in to comment.