Skip to content

Commit 847cb7b

Browse files
committed
Improve spec for provided features, i.e., requires done during startup
1 parent d1e32df commit 847cb7b

File tree

5 files changed

+24
-14
lines changed

5 files changed

+24
-14
lines changed

spec/ruby/core/kernel/require_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@
1616
Kernel.should have_private_instance_method(:require)
1717
end
1818

19+
provided = %w[complex enumerator rational thread ruby2_keywords]
20+
ruby_version_is "3.1" do
21+
provided << "fiber"
22+
end
23+
24+
it "#{provided.join(', ')} are already required" do
25+
out = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems --disable-did-you-mean')
26+
features = out.lines.map { |line| File.basename(line.chomp, '.*') }
27+
features -= %w[encdb transdb] # Ignore CRuby internals
28+
features.sort.should == provided.sort
29+
30+
code = provided.map { |f| "puts require #{f.inspect}\n" }.join
31+
required = ruby_exe(code, options: '--disable-gems')
32+
required.should == "false\n" * provided.size
33+
end
34+
1935
it_behaves_like :kernel_require_basic, :require, CodeLoadingSpecs::Method.new
2036
it_behaves_like :kernel_require, :require, CodeLoadingSpecs::Method.new
2137
end

spec/ruby/core/kernel/shared/require.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -546,20 +546,6 @@
546546
ScratchPad.recorded.should == []
547547
end
548548

549-
provided = %w[complex enumerator rational thread]
550-
provided << 'ruby2_keywords'
551-
552-
it "#{provided.join(', ')} are already required" do
553-
features = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems')
554-
provided.each { |feature|
555-
features.should =~ /\b#{feature}\.(rb|so|jar)$/
556-
}
557-
558-
code = provided.map { |f| "puts require #{f.inspect}\n" }.join
559-
required = ruby_exe(code, options: '--disable-gems')
560-
required.should == "false\n" * provided.size
561-
end
562-
563549
it "unicode_normalize is part of core and not $LOADED_FEATURES" do
564550
features = ruby_exe("puts $LOADED_FEATURES", options: '--disable-gems')
565551
features.lines.each { |feature|

spec/ruby/library/fiber/current_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
require 'fiber'
44

55
describe "Fiber.current" do
6+
ruby_version_is "3.1" do
7+
it "is available without an extra require" do
8+
ruby_exe("print Fiber.current.class", options: '--disable-gems --disable-did-you-mean').should == "Fiber"
9+
end
10+
end
11+
612
it "returns the root Fiber when called outside of a Fiber" do
713
root = Fiber.current
814
root.should be_an_instance_of(Fiber)

spec/tags/core/kernel/require_tags.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ fails:Kernel#require (non-extensioned path) loads a .rb extensioned file when a
66
fails:Kernel#require (non-extensioned path) does not load a feature twice when $LOAD_PATH has been modified
77
slow:Kernel#require ($LOADED_FEATURES) complex, enumerator, rational, thread, ruby2_keywords are already required
88
slow:Kernel.require ($LOADED_FEATURES) complex, enumerator, rational, thread, ruby2_keywords are already required
9+
slow:Kernel#require complex, enumerator, rational, thread, ruby2_keywords, fiber are already required
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
slow:Fiber.current is available without an extra require

0 commit comments

Comments
 (0)