Skip to content

Commit

Permalink
Autoload const removing behavior is the same on 1.8 and 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
dbussink committed Jun 30, 2012
1 parent bbf6013 commit a9c54b8
Showing 1 changed file with 16 additions and 36 deletions.
52 changes: 16 additions & 36 deletions spec/ruby/core/module/autoload_spec.rb
Expand Up @@ -154,48 +154,28 @@ class ModuleSpecs::Autoload::HClass
ModuleSpecs::Autoload.use_ex1.should == :good
end

ruby_version_is "" ... "1.9" do
it "removes the constant from the constant table if load fails" do
ModuleSpecs::Autoload.autoload :Fail, @non_existent
ModuleSpecs::Autoload.should have_constant(:Fail)

lambda { ModuleSpecs::Autoload::Fail }.should raise_error(LoadError)
ModuleSpecs::Autoload.should_not have_constant(:Fail)
end

it "removes the constant from the constant table if the loaded files does not define it" do
ModuleSpecs::Autoload.autoload :O, fixture(__FILE__, "autoload_o.rb")
ModuleSpecs::Autoload.should have_constant(:O)

lambda { ModuleSpecs::Autoload::O }.should raise_error(NameError)
ModuleSpecs::Autoload.should_not have_constant(:O)
end

it "does not load the file when refering to the constant in defined?" do
module ModuleSpecs::Autoload::Q
autoload :R, fixture(__FILE__, "autoload.rb")
defined?(R).should == "constant"
end
ModuleSpecs::Autoload::Q.should have_constant(:R)
it "does not load the file when refering to the constant in defined?" do
module ModuleSpecs::Autoload::Q
autoload :R, fixture(__FILE__, "autoload.rb")
defined?(R).should == "constant"
end
ModuleSpecs::Autoload::Q.should have_constant(:R)
end

ruby_version_is "1.9" do
it "does not remove the constant from the constant table if load fails" do
ModuleSpecs::Autoload.autoload :Fail, @non_existent
ModuleSpecs::Autoload.should have_constant(:Fail)
it "does not remove the constant from the constant table if load fails" do
ModuleSpecs::Autoload.autoload :Fail, @non_existent
ModuleSpecs::Autoload.should have_constant(:Fail)

lambda { ModuleSpecs::Autoload::Fail }.should raise_error(LoadError)
ModuleSpecs::Autoload.should have_constant(:Fail)
end
lambda { ModuleSpecs::Autoload::Fail }.should raise_error(LoadError)
ModuleSpecs::Autoload.should have_constant(:Fail)
end

it "does not remove the constant from the constant table if the loaded files does not define it" do
ModuleSpecs::Autoload.autoload :O, fixture(__FILE__, "autoload_o.rb")
ModuleSpecs::Autoload.should have_constant(:O)
it "does not remove the constant from the constant table if the loaded files does not define it" do
ModuleSpecs::Autoload.autoload :O, fixture(__FILE__, "autoload_o.rb")
ModuleSpecs::Autoload.should have_constant(:O)

lambda { ModuleSpecs::Autoload::O }.should raise_error(NameError)
ModuleSpecs::Autoload.should have_constant(:O)
end
lambda { ModuleSpecs::Autoload::O }.should raise_error(NameError)
ModuleSpecs::Autoload.should have_constant(:O)
end

ruby_version_is '1.9' ... '1.9.3' do
Expand Down

0 comments on commit a9c54b8

Please sign in to comment.