mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 22:14:37 +02:00
Update to ruby/spec@abf1700
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6a4aa4838c
commit
5b593e3889
79 changed files with 1555 additions and 304 deletions
|
@ -414,7 +414,7 @@ describe "Module#autoload" do
|
|||
mod_names = []
|
||||
mod_count.times do |i|
|
||||
mod_name = :"Mod#{i}"
|
||||
autoload mod_name, autoload_path
|
||||
Object.autoload mod_name, autoload_path
|
||||
mod_names << mod_name
|
||||
end
|
||||
|
||||
|
|
|
@ -151,10 +151,10 @@ end
|
|||
describe "Module#module_function as a toggle (no arguments) in a Module body" do
|
||||
it "makes any subsequently defined methods module functions with the normal semantics" do
|
||||
m = Module.new {
|
||||
module_function
|
||||
def test1() end
|
||||
def test2() end
|
||||
}
|
||||
module_function
|
||||
def test1() end
|
||||
def test2() end
|
||||
}
|
||||
|
||||
m.respond_to?(:test1).should == true
|
||||
m.respond_to?(:test2).should == true
|
||||
|
@ -172,12 +172,12 @@ describe "Module#module_function as a toggle (no arguments) in a Module body" do
|
|||
it "stops creating module functions if the body encounters another toggle " \
|
||||
"like public/protected/private without arguments" do
|
||||
m = Module.new {
|
||||
module_function
|
||||
def test1() end
|
||||
def test2() end
|
||||
public
|
||||
def test3() end
|
||||
}
|
||||
module_function
|
||||
def test1() end
|
||||
def test2() end
|
||||
public
|
||||
def test3() end
|
||||
}
|
||||
|
||||
m.respond_to?(:test1).should == true
|
||||
m.respond_to?(:test2).should == true
|
||||
|
@ -187,16 +187,13 @@ describe "Module#module_function as a toggle (no arguments) in a Module body" do
|
|||
it "does not stop creating module functions if the body encounters " \
|
||||
"public/protected/private WITH arguments" do
|
||||
m = Module.new {
|
||||
def foo() end
|
||||
|
||||
module_function
|
||||
def test1() end
|
||||
def test2() end
|
||||
|
||||
public :foo
|
||||
|
||||
def test3() end
|
||||
}
|
||||
def foo() end
|
||||
module_function
|
||||
def test1() end
|
||||
def test2() end
|
||||
public :foo
|
||||
def test3() end
|
||||
}
|
||||
|
||||
m.respond_to?(:test1).should == true
|
||||
m.respond_to?(:test2).should == true
|
||||
|
@ -205,11 +202,10 @@ describe "Module#module_function as a toggle (no arguments) in a Module body" do
|
|||
|
||||
it "does not affect module_evaled method definitions also if outside the eval itself" do
|
||||
m = Module.new {
|
||||
module_function
|
||||
|
||||
module_eval { def test1() end }
|
||||
module_eval " def test2() end "
|
||||
}
|
||||
module_function
|
||||
module_eval { def test1() end }
|
||||
module_eval " def test2() end "
|
||||
}
|
||||
|
||||
m.respond_to?(:test1).should == false
|
||||
m.respond_to?(:test2).should == false
|
||||
|
@ -217,11 +213,10 @@ describe "Module#module_function as a toggle (no arguments) in a Module body" do
|
|||
|
||||
it "has no effect if inside a module_eval if the definitions are outside of it" do
|
||||
m = Module.new {
|
||||
module_eval { module_function }
|
||||
|
||||
def test1() end
|
||||
def test2() end
|
||||
}
|
||||
module_eval { module_function }
|
||||
def test1() end
|
||||
def test2() end
|
||||
}
|
||||
|
||||
m.respond_to?(:test1).should == false
|
||||
m.respond_to?(:test2).should == false
|
||||
|
@ -229,13 +224,12 @@ describe "Module#module_function as a toggle (no arguments) in a Module body" do
|
|||
|
||||
it "functions normally if both toggle and definitions inside a module_eval" do
|
||||
m = Module.new {
|
||||
module_eval {
|
||||
module_function
|
||||
|
||||
def test1() end
|
||||
def test2() end
|
||||
}
|
||||
}
|
||||
module_eval {
|
||||
module_function
|
||||
def test1() end
|
||||
def test2() end
|
||||
}
|
||||
}
|
||||
|
||||
m.respond_to?(:test1).should == true
|
||||
m.respond_to?(:test2).should == true
|
||||
|
@ -243,10 +237,9 @@ describe "Module#module_function as a toggle (no arguments) in a Module body" do
|
|||
|
||||
it "affects evaled method definitions also even when outside the eval itself" do
|
||||
m = Module.new {
|
||||
module_function
|
||||
|
||||
eval "def test1() end"
|
||||
}
|
||||
module_function
|
||||
eval "def test1() end"
|
||||
}
|
||||
|
||||
m.respond_to?(:test1).should == true
|
||||
end
|
||||
|
@ -254,7 +247,6 @@ describe "Module#module_function as a toggle (no arguments) in a Module body" do
|
|||
it "doesn't affect definitions when inside an eval even if the definitions are outside of it" do
|
||||
m = Module.new {
|
||||
eval "module_function"
|
||||
|
||||
def test1() end
|
||||
}
|
||||
|
||||
|
@ -263,13 +255,13 @@ describe "Module#module_function as a toggle (no arguments) in a Module body" do
|
|||
|
||||
it "functions normally if both toggle and definitions inside a eval" do
|
||||
m = Module.new {
|
||||
eval <<-CODE
|
||||
module_function
|
||||
eval <<-CODE
|
||||
module_function
|
||||
|
||||
def test1() end
|
||||
def test2() end
|
||||
CODE
|
||||
}
|
||||
def test1() end
|
||||
def test2() end
|
||||
CODE
|
||||
}
|
||||
|
||||
m.respond_to?(:test1).should == true
|
||||
m.respond_to?(:test2).should == true
|
||||
|
|
|
@ -9,11 +9,11 @@ describe :set_visibility, shared: true do
|
|||
it "sets visibility to following method definitions" do
|
||||
visibility = @method
|
||||
mod = Module.new {
|
||||
send visibility
|
||||
send visibility
|
||||
|
||||
def test1() end
|
||||
def test2() end
|
||||
}
|
||||
def test1() end
|
||||
def test2() end
|
||||
}
|
||||
|
||||
mod.should send(:"have_#{@method}_instance_method", :test1, false)
|
||||
mod.should send(:"have_#{@method}_instance_method", :test2, false)
|
||||
|
@ -23,11 +23,11 @@ describe :set_visibility, shared: true do
|
|||
visibility = @method
|
||||
new_visibility = nil
|
||||
mod = Module.new {
|
||||
send visibility
|
||||
new_visibility = [:protected, :private].find {|vis| vis != visibility }
|
||||
send new_visibility
|
||||
def test1() end
|
||||
}
|
||||
send visibility
|
||||
new_visibility = [:protected, :private].find {|vis| vis != visibility }
|
||||
send new_visibility
|
||||
def test1() end
|
||||
}
|
||||
|
||||
mod.should send(:"have_#{new_visibility}_instance_method", :test1, false)
|
||||
end
|
||||
|
@ -35,11 +35,11 @@ describe :set_visibility, shared: true do
|
|||
it "continues setting visibility if the body encounters other visibility setters with arguments" do
|
||||
visibility = @method
|
||||
mod = Module.new {
|
||||
send visibility
|
||||
def test1() end
|
||||
send([:protected, :private].find {|vis| vis != visibility }, :test1)
|
||||
def test2() end
|
||||
}
|
||||
send visibility
|
||||
def test1() end
|
||||
send([:protected, :private].find {|vis| vis != visibility }, :test1)
|
||||
def test2() end
|
||||
}
|
||||
|
||||
mod.should send(:"have_#{@method}_instance_method", :test2, false)
|
||||
end
|
||||
|
@ -47,11 +47,11 @@ describe :set_visibility, shared: true do
|
|||
it "does not affect module_evaled method definitions when itself is outside the eval" do
|
||||
visibility = @method
|
||||
mod = Module.new {
|
||||
send visibility
|
||||
send visibility
|
||||
|
||||
module_eval { def test1() end }
|
||||
module_eval " def test2() end "
|
||||
}
|
||||
module_eval { def test1() end }
|
||||
module_eval " def test2() end "
|
||||
}
|
||||
|
||||
mod.should have_public_instance_method(:test1, false)
|
||||
mod.should have_public_instance_method(:test2, false)
|
||||
|
@ -60,10 +60,10 @@ describe :set_visibility, shared: true do
|
|||
it "does not affect outside method definitions when itself is inside a module_eval" do
|
||||
visibility = @method
|
||||
mod = Module.new {
|
||||
module_eval { send visibility }
|
||||
module_eval { send visibility }
|
||||
|
||||
def test1() end
|
||||
}
|
||||
def test1() end
|
||||
}
|
||||
|
||||
mod.should have_public_instance_method(:test1, false)
|
||||
end
|
||||
|
@ -71,12 +71,12 @@ describe :set_visibility, shared: true do
|
|||
it "affects normally if itself and method definitions are inside a module_eval" do
|
||||
visibility = @method
|
||||
mod = Module.new {
|
||||
module_eval {
|
||||
send visibility
|
||||
module_eval {
|
||||
send visibility
|
||||
|
||||
def test1() end
|
||||
}
|
||||
}
|
||||
def test1() end
|
||||
}
|
||||
}
|
||||
|
||||
mod.should send(:"have_#{@method}_instance_method", :test1, false)
|
||||
end
|
||||
|
@ -85,11 +85,11 @@ describe :set_visibility, shared: true do
|
|||
visibility = @method
|
||||
initialized_visibility = [:public, :protected, :private].find {|sym| sym != visibility }
|
||||
mod = Module.new {
|
||||
send initialized_visibility
|
||||
eval visibility.to_s
|
||||
send initialized_visibility
|
||||
eval visibility.to_s
|
||||
|
||||
def test1() end
|
||||
}
|
||||
def test1() end
|
||||
}
|
||||
|
||||
mod.should send(:"have_#{initialized_visibility}_instance_method", :test1, false)
|
||||
end
|
||||
|
@ -97,10 +97,10 @@ describe :set_visibility, shared: true do
|
|||
it "affects evaled method definitions when itself is outside the eval" do
|
||||
visibility = @method
|
||||
mod = Module.new {
|
||||
send visibility
|
||||
send visibility
|
||||
|
||||
eval "def test1() end"
|
||||
}
|
||||
eval "def test1() end"
|
||||
}
|
||||
|
||||
mod.should send(:"have_#{@method}_instance_method", :test1, false)
|
||||
end
|
||||
|
@ -108,12 +108,12 @@ describe :set_visibility, shared: true do
|
|||
it "affects normally if itself and following method definitions are inside a eval" do
|
||||
visibility = @method
|
||||
mod = Module.new {
|
||||
eval <<-CODE
|
||||
#{visibility}
|
||||
eval <<-CODE
|
||||
#{visibility}
|
||||
|
||||
def test1() end
|
||||
CODE
|
||||
}
|
||||
def test1() end
|
||||
CODE
|
||||
}
|
||||
|
||||
mod.should send(:"have_#{@method}_instance_method", :test1, false)
|
||||
end
|
||||
|
@ -122,11 +122,11 @@ describe :set_visibility, shared: true do
|
|||
it "sets the visibility outside the closure" do
|
||||
visibility = @method
|
||||
mod = Module.new {
|
||||
1.times {
|
||||
send visibility
|
||||
}
|
||||
def test1() end
|
||||
}
|
||||
1.times {
|
||||
send visibility
|
||||
}
|
||||
def test1() end
|
||||
}
|
||||
|
||||
mod.should send(:"have_#{@method}_instance_method", :test1, false)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue