summaryrefslogtreecommitdiff
path: root/test/test_sorted_set.rb
diff options
context:
space:
mode:
authorAkinori MUSHA <knu@idaemons.org>2020-12-22 12:20:21 +0900
committerAkinori MUSHA <knu@idaemons.org>2020-12-22 12:20:21 +0900
commit3fa4bd82928983cf5f6711c130711502397e05e2 (patch)
treedb80a406ef9497d1e53ac26c43ffa275edf2e61e /test/test_sorted_set.rb
parent63b872c409ec441718f55c60362a441cf108cfc0 (diff)
downloadruby-3fa4bd82928983cf5f6711c130711502397e05e2.tar.gz
Import set 1.0.0
- SortedSet has been removed for dependency and performance reasons. - Set#join is added as a shorthand for `.to_a.join`. - Set#<=> is added. https://github.com/ruby/set/blob/v1.0.0/CHANGELOG.md
Diffstat (limited to 'test/test_sorted_set.rb')
-rw-r--r--test/test_sorted_set.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/test_sorted_set.rb b/test/test_sorted_set.rb
new file mode 100644
index 0000000000..1ac6ee929a
--- /dev/null
+++ b/test/test_sorted_set.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: false
+require 'test/unit'
+require 'set'
+
+class TC_SortedSet < Test::Unit::TestCase
+ def base_dir
+ "#{__dir__}/../lib"
+ end
+
+ def assert_runs(ruby, options: nil)
+ options = ['-I', base_dir, *options]
+ r = system(RbConfig.ruby, *options, '-e', ruby)
+ assert(r)
+ end
+
+ def test_error
+ assert_runs <<~RUBY
+ require "set"
+
+ r = begin
+ puts SortedSet.new
+ rescue Exception => e
+ e.message
+ end
+ raise r unless r.match? /has been extracted/
+ RUBY
+ end
+
+ def test_ok_with_gem
+ assert_runs <<~RUBY, options: ['-I', "#{__dir__}/fixtures/fake_sorted_set_gem"]
+ require "set"
+
+ var = SortedSet.new.to_s
+ RUBY
+ end
+
+ def test_ok_require
+ assert_runs <<~RUBY, options: ['-I', "#{__dir__}/fixtures/fake_sorted_set_gem"]
+ require "set"
+ require "sorted_set"
+
+ var = SortedSet.new.to_s
+ RUBY
+ end
+end