1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/spec/ruby/library/set/comparison_spec.rb
2021-10-20 21:41:46 +02:00

29 lines
836 B
Ruby

require_relative '../../spec_helper'
require 'set'
ruby_version_is "3.0" do
describe "Set#<=>" do
it "returns 0 if the sets are equal" do
(Set[] <=> Set[]).should == 0
(Set[:a, :b, :c] <=> Set[:a, :b, :c]).should == 0
end
it "returns -1 if the set is a proper subset of the other set" do
(Set[] <=> Set[1]).should == -1
(Set[1, 2] <=> Set[1, 2, 3]).should == -1
end
it "returns +1 if the set is a proper superset of other set" do
(Set[1] <=> Set[]).should == +1
(Set[1, 2, 3] <=> Set[1, 2]).should == +1
end
it "returns nil if the set has unique elements" do
(Set[1, 2, 3] <=> Set[:a, :b, :c]).should be_nil
end
it "returns nil when the argument is not set-like" do
(Set[] <=> false).should be_nil
end
end
end