Project

General

Profile

Feature #14396 ยป return_values_of_visibility_methods.diff

usa (Usaku NAKAMURA), 01/24/2018 09:13 PM

View differences:

spec/ruby/core/main/private_spec.rb (working copy)
Object.should have_private_method(:main_public_method)
end
it "returns Object" do
eval("private :main_public_method", TOPLEVEL_BINDING).should equal(Object)
ruby_version_is ""..."2.6" do
it "returns Object" do
eval("private :main_public_method", TOPLEVEL_BINDING).should equal(Object)
end
end
ruby_version_is "2.6" do
it "returns the argument(s) or Object" do
eval("private :main_public_method", TOPLEVEL_BINDING).should equal(:main_public_method)
eval("private :main_public_method, :main_private_method", TOPLEVEL_BINDING).should eql([:main_public_method, :main_private_method])
eval("private", TOPLEVEL_BINDING).should equal(Object)
end
end
it "raises a NameError when given an undefined name" do
lambda do
eval "private :main_undefined_method", TOPLEVEL_BINDING
spec/ruby/core/main/public_spec.rb (working copy)
Object.should_not have_private_method(:main_private_method)
end
it "returns Object" do
eval("public :main_private_method", TOPLEVEL_BINDING).should equal(Object)
ruby_version_is ""..."2.6" do
it "returns Object" do
eval("public :main_private_method", TOPLEVEL_BINDING).should equal(Object)
end
end
ruby_version_is "2.6" do
it "returns the argument(s) or Object" do
eval("public :main_private_method", TOPLEVEL_BINDING).should equal(:main_private_method)
eval("public :main_private_method, :main_public_method", TOPLEVEL_BINDING).should eql([:main_private_method, :main_public_method])
eval("public", TOPLEVEL_BINDING).should equal(Object)
end
end
it "raises a NameError when given an undefined name" do
lambda do
eval "public :main_undefined_method", TOPLEVEL_BINDING
spec/ruby/core/module/private_spec.rb (working copy)
:module_specs_public_method_on_object_for_kernel_private)
end
it "returns self" do
(class << Object.new; self; end).class_eval do
def foo; end
private(:foo).should equal(self)
private.should equal(self)
ruby_version_is ""..."2.6" do
it "returns self" do
(class << Object.new; self; end).class_eval do
def foo; end
private(:foo).should equal(self)
private.should equal(self)
end
end
end
ruby_version_is "2.6" do
it "returns the argument(s) or self" do
(class << Object.new; self; end).class_eval do
def foo; end
def bar; end
private(:foo).should equal(:foo)
private(:foo, :bar).should eql([:foo, :bar])
private.should equal(self)
end
end
end
it "raises a NameError when given an undefined name" do
lambda do
Module.new.send(:private, :undefined)
spec/ruby/core/module/protected_spec.rb (working copy)
:module_specs_public_method_on_object_for_kernel_protected)
end
it "returns self" do
(class << Object.new; self; end).class_eval do
def foo; end
protected(:foo).should equal(self)
protected.should equal(self)
ruby_version_is ""..."2.6" do
it "returns self" do
(class << Object.new; self; end).class_eval do
def foo; end
protected(:foo).should equal(self)
protected.should equal(self)
end
end
end
ruby_version_is "2.6" do
it "returns the argument(s) or self" do
(class << Object.new; self; end).class_eval do
def foo; end
def bar; end
protected(:foo).should equal(:foo)
protected(:foo, :bar).should eql([:foo, :bar])
protected.should equal(self)
end
end
end
it "raises a NameError when given an undefined name" do
lambda do
Module.new.send(:protected, :undefined)
spec/ruby/core/module/public_spec.rb (working copy)
:module_specs_private_method_on_object_for_kernel_public)
end
it "returns self" do
(class << Object.new; self; end).class_eval do
def foo; end
private :foo
public(:foo).should equal(self)
public.should equal(self)
ruby_version_is ""..."2.6" do
it "returns self" do
(class << Object.new; self; end).class_eval do
def foo; end
private :foo
public(:foo).should equal(self)
public.should equal(self)
end
end
end
ruby_version_is "2.6" do
it "returns the arugment(s) or self" do
(class << Object.new; self; end).class_eval do
def foo; end
def bar; end
private :foo, :bar
public(:foo).should equal(:foo)
public(:foo, :bar).should eql([:foo, :bar])
public.should equal(self)
end
end
end
it "raises a NameError when given an undefined name" do
lambda do
Module.new.send(:public, :undefined)
vm_method.c (working copy)
{
if (argc == 0) {
rb_scope_visibility_set(visi);
return module;
}
else {
set_method_visibility(module, argc, argv, visi);
if (argc == 1) {
return *argv;
}
else {
return rb_ary_new_from_values(argc, argv);
}
}
return module;
}
/*
* call-seq:
* public -> self
* public(symbol, ...) -> self
* public(string, ...) -> self
* public(symbol, ...) -> aSymbol or [symbol, ...]
* public(string, ...) -> sString or [string, ...]
*
* With no arguments, sets the default visibility for subsequently
* defined methods to public. With arguments, sets the named methods to
......
/*
* call-seq:
* protected -> self
* protected(symbol, ...) -> self
* protected(string, ...) -> self
* protected(symbol, ...) -> aSymbol or [symbol, ...]
* protected(string, ...) -> aString or [string, ...]
*
* With no arguments, sets the default visibility for subsequently
* defined methods to protected. With arguments, sets the named methods
......
/*
* call-seq:
* private -> self
* private(symbol, ...) -> self
* private(string, ...) -> self
* private(symbol, ...) -> aSymbol or [symbol, ...]
* private(string, ...) -> aString or [string, ...]
*
* With no arguments, sets the default visibility for subsequently
* defined methods to private. With arguments, sets the named methods
    (1-1/1)