Remove SortedSet autoload and set/sorted_set
Implements [Feature #21287]
This commit is contained in:
parent
a7ef9a44a6
commit
c52f4eea56
Notes:
git
2025-05-20 04:34:46 +00:00
6
NEWS.md
6
NEWS.md
@ -105,6 +105,11 @@ The following bundled gems are updated.
|
||||
|
||||
[[Feature #21258]]
|
||||
|
||||
* With the move of `Set` from stdlib to core class, `set/sorted_set.rb` has
|
||||
been removed, and `SortedSet` is no longer an autoloaded constant. Please
|
||||
install the `sorted_set` gem and `require 'sorted_set'` to use `SortedSet`.
|
||||
[[Feature #21287]]
|
||||
|
||||
## C API updates
|
||||
|
||||
* IO
|
||||
@ -130,3 +135,4 @@ The following bundled gems are updated.
|
||||
[Bug #21049]: https://bugs.ruby-lang.org/issues/21049
|
||||
[Feature #21216]: https://bugs.ruby-lang.org/issues/21216
|
||||
[Feature #21258]: https://bugs.ruby-lang.org/issues/21258
|
||||
[Feature #21287]: https://bugs.ruby-lang.org/issues/21287
|
||||
|
@ -1,6 +0,0 @@
|
||||
begin
|
||||
require 'sorted_set'
|
||||
rescue ::LoadError
|
||||
raise "The `SortedSet` class has been extracted from the `set` library. " \
|
||||
"You must use the `sorted_set` gem or other alternatives."
|
||||
end
|
@ -26,8 +26,6 @@ module Kernel
|
||||
private :pp
|
||||
end
|
||||
|
||||
autoload :SortedSet, 'set/sorted_set'
|
||||
|
||||
module Enumerable
|
||||
# Makes a set from the enumerable object with given arguments.
|
||||
def to_set(klass = Set, *args, &block)
|
||||
|
@ -1,6 +1,7 @@
|
||||
require_relative '../../../spec_helper'
|
||||
|
||||
describe "SortedSet" do
|
||||
ruby_version_is ""..."3.5" do
|
||||
it "raises error including message that it has been extracted from the set stdlib" do
|
||||
-> {
|
||||
SortedSet
|
||||
@ -9,3 +10,4 @@ describe "SortedSet" do
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,9 +0,0 @@
|
||||
Object.instance_exec do
|
||||
# Remove the constant to cancel autoload that would be fired by
|
||||
# `class SortedSet` and cause circular require.
|
||||
remove_const :SortedSet if const_defined?(:SortedSet)
|
||||
end
|
||||
|
||||
class SortedSet < Set
|
||||
# ...
|
||||
end
|
@ -1,45 +0,0 @@
|
||||
# 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
|
Loading…
x
Reference in New Issue
Block a user