diff --git a/activesupport/test/autoloading_fixtures/throws.rb b/activesupport/test/autoloading_fixtures/throws.rb new file mode 100644 index 0000000000..55ce509410 --- /dev/null +++ b/activesupport/test/autoloading_fixtures/throws.rb @@ -0,0 +1,3 @@ +Throws = 1 + +throw :t diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index b7a5747f1b..1f9f8aebd3 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -269,6 +269,17 @@ class DependenciesTest < ActiveSupport::TestCase remove_constants(:ModuleFolder) end + def test_throwing_removes_autoloaded_constants + with_autoloading_fixtures do + catch :t do + Throws + end + assert !Object.const_defined?(:Throws) + end + ensure + remove_constants(:Throws) + end + def test_doesnt_break_normal_require path = File.expand_path("../autoloading_fixtures/load_path", __FILE__) original_path = $:.dup