mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 21:14:23 +02:00
Make Set a builtin feature [Feature #16989]
This commit is contained in:
parent
7757ccb504
commit
dd3501bb95
Notes:
git
2022-02-18 11:56:45 +09:00
3 changed files with 49 additions and 1 deletions
|
@ -838,3 +838,42 @@ class TC_Enumerable < Test::Unit::TestCase
|
|||
assert_not_same set, set.to_set { |o| o }
|
||||
end
|
||||
end
|
||||
|
||||
class TC_Set_Builtin < Test::Unit::TestCase
|
||||
private def should_omit?
|
||||
Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.2.0') ||
|
||||
!File.exist?(File.expand_path('../prelude.rb', __dir__))
|
||||
end
|
||||
|
||||
def test_Set
|
||||
omit "skipping the test for the builtin Set" if should_omit?
|
||||
|
||||
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
|
||||
begin;
|
||||
assert_nothing_raised do
|
||||
set = Set.new([1, 2])
|
||||
assert_equal('Set', set.class.name)
|
||||
end
|
||||
end;
|
||||
|
||||
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
|
||||
begin;
|
||||
assert_nothing_raised do
|
||||
set = Set[1, 2]
|
||||
assert_equal('Set', set.class.name)
|
||||
end
|
||||
end;
|
||||
end
|
||||
|
||||
def test_to_set
|
||||
omit "skipping the test for the builtin Enumerable#to_set" if should_omit?
|
||||
|
||||
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
|
||||
begin;
|
||||
assert_nothing_raised do
|
||||
set = [1, 2].to_set
|
||||
assert_equal('Set', set.class.name)
|
||||
end
|
||||
end;
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue