Project

General

Profile

Bug #12970 » fix_recursive_sets.patch

Esse (Piotr Szmielew), 12/23/2016 09:54 PM

View differences:

lib/set.rb
# add many elements at once.
def add(o)
@hash[o] = true
@hash.rehash if o == self
self
end
alias << add
test/test_set.rb
}
end
def test_recursive_superset?
recursive_set_1 = Set.new([1, 2]).tap {|s| s << s}
recursive_set_2 = Set.new([1, 2]).tap {|s| s << s}
assert recursive_set_1.superset?(recursive_set_1)
assert recursive_set_2.superset?(recursive_set_1)
assert recursive_set_1.superset?(recursive_set_2)
end
def test_proper_superset?
set = Set[1,2,3]
......
}
end
def test_recursive_subset?
recursive_set_1 = Set.new([1, 2]).tap {|s| s << s}
recursive_set_2 = Set.new([1, 2]).tap {|s| s << s}
assert recursive_set_1.subset?(recursive_set_1)
assert recursive_set_1.subset?(recursive_set_2)
assert recursive_set_2.subset?(recursive_set_1)
end
def test_proper_subset?
set = Set[1,2,3]
......
assert_not_equal(Set[Exception.new,nil], Set[Exception.new,Exception.new], "[ruby-dev:26127]")
end
def test_recursive_eq
recursive_set_1 = Set.new([1, 2]).tap {|s| s << s}
recursive_set_2 = Set.new([1, 2]).tap {|s| s << s}
assert_equal(recursive_set_1, recursive_set_1)
assert_equal(recursive_set_1, recursive_set_2)
end
def test_classify
set = Set.new(1..10)
ret = set.classify { |i| i % 3 }
(2-2/2)