summaryrefslogtreecommitdiff
path: root/spec/ruby/core/module/module_function_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/module/module_function_spec.rb')
-rw-r--r--spec/ruby/core/module/module_function_spec.rb40
1 files changed, 28 insertions, 12 deletions
diff --git a/spec/ruby/core/module/module_function_spec.rb b/spec/ruby/core/module/module_function_spec.rb
index 407237d48f..0602e95ca9 100644
--- a/spec/ruby/core/module/module_function_spec.rb
+++ b/spec/ruby/core/module/module_function_spec.rb
@@ -38,14 +38,23 @@ describe "Module#module_function with specific method names" do
m.respond_to?(:test3).should == false
end
- it "returns the current module" do
- x = nil
- m = Module.new do
- def test() end
- x = module_function :test
+ ruby_version_is ""..."3.1" do
+ it "returns self" do
+ Module.new do
+ def foo; end
+ module_function(:foo).should equal(self)
+ end
end
+ end
- x.should == m
+ ruby_version_is "3.1" do
+ it "returns argument or arguments if given" do
+ Module.new do
+ def foo; end
+ module_function(:foo).should equal(:foo)
+ module_function(:foo, :foo).should == [:foo, :foo]
+ end
+ end
end
it "creates an independent copy of the method, not a redirect" do
@@ -160,13 +169,20 @@ describe "Module#module_function as a toggle (no arguments) in a Module body" do
m.respond_to?(:test2).should == true
end
- it "returns the current module" do
- x = nil
- m = Module.new {
- x = module_function
- }
+ ruby_version_is ""..."3.1" do
+ it "returns self" do
+ Module.new do
+ module_function.should equal(self)
+ end
+ end
+ end
- x.should == m
+ ruby_version_is "3.1" do
+ it "returns nil" do
+ Module.new do
+ module_function.should equal(nil)
+ end
+ end
end
it "stops creating module functions if the body encounters another toggle " \