Changeset 4779
- Timestamp:
- 08/16/06 20:54:25 (2 years ago)
- Files:
-
- trunk/activesupport/lib/active_support/dependencies.rb (modified) (2 diffs)
- trunk/activesupport/test/dependencies_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/lib/active_support/dependencies.rb
r4778 r4779 66 66 # infinite loop with mutual dependencies. 67 67 loaded << expanded 68 68 69 69 if load? 70 70 log "loading #{file_name}" … … 179 179 def load_missing_constant(from_mod, const_name) 180 180 log_call from_mod, const_name 181 182 # If we have an anonymous module, all we can do is attempt to load from Object. 183 from_mod = Object if from_mod.name.empty? 184 185 raise ArgumentError, "Expected #{from_mod} is not missing constant #{const_name}!" if from_mod.const_defined?(const_name) 181 186 182 187 qualified_name = qualified_name_for from_mod, const_name trunk/activesupport/test/dependencies_test.rb
r4778 r4779 347 347 348 348 def test_const_missing_should_not_double_load 349 $counting_loaded_times = 0 349 350 with_loading 'autoloading_fixtures' do 350 351 require_dependency '././counting_loader' 351 352 assert_equal 1, $counting_loaded_times 352 Dependencies.load_missing_constant Object, :CountingLoader353 assert_raises(ArgumentError) { Dependencies.load_missing_constant Object, :CountingLoader } 353 354 assert_equal 1, $counting_loaded_times 354 355 end 355 356 end 356 357 358 def test_const_missing_within_anonymous_module 359 $counting_loaded_times = 0 360 m = Module.new 361 m.module_eval "def a() CountingLoader; end" 362 extend m 363 kls = nil 364 with_loading 'autoloading_fixtures' do 365 kls = nil 366 assert_nothing_raised { kls = a } 367 assert_equal "CountingLoader", kls.name 368 assert_equal 1, $counting_loaded_times 369 370 assert_nothing_raised { kls = a } 371 assert_equal 1, $counting_loaded_times 372 end 373 end 374 357 375 end