summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAkinori MUSHA <knu@idaemons.org>2022-02-17 18:02:42 +0900
committerAkinori MUSHA <knu@idaemons.org>2022-02-18 11:56:24 +0900
commitdd3501bb9580951623a9aa7c2f86f7c98f9d6b9c (patch)
tree5f05faf3bf6f366f988a0f6a9996e4249d97308d /test
parent7757ccb5048b964642a0c884906e35c5fab634f3 (diff)
Make Set a builtin feature [Feature #16989]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5563
Diffstat (limited to 'test')
-rw-r--r--test/test_set.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/test_set.rb b/test/test_set.rb
index b92930a445..83e28878a0 100644
--- a/test/test_set.rb
+++ b/test/test_set.rb
@@ -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