@@ -299,25 +299,28 @@ module ModuleSpecs::Autoload
299
299
autoload :RequiredDirectlyNoConstant , fixture ( __FILE__ , "autoload_required_directly_no_constant.rb" )
300
300
end
301
301
@path = fixture ( __FILE__ , "autoload_required_directly_no_constant.rb" )
302
- @remove << :RequiredDirectlyNoConstant
303
302
@check = -> {
304
303
[
305
304
defined? ( ModuleSpecs ::Autoload ::RequiredDirectlyNoConstant ) ,
306
- ModuleSpecs ::Autoload . constants ( false ) . include? ( :RequiredDirectlyNoConstant ) ,
307
305
ModuleSpecs ::Autoload . const_defined? ( :RequiredDirectlyNoConstant ) ,
308
306
ModuleSpecs ::Autoload . autoload? ( :RequiredDirectlyNoConstant )
309
307
]
310
308
}
311
309
ScratchPad . record @check
312
- @check . call . should == [ "constant" , true , true , @path ]
310
+ @check . call . should == [ "constant" , true , @path ]
313
311
$:. push File . dirname ( @path )
314
312
begin
315
313
require "autoload_required_directly_no_constant.rb"
316
314
ensure
317
315
$:. pop
318
316
end
319
- ScratchPad . recorded . should == [ nil , true , false , nil ]
320
- @check . call . should == [ nil , true , false , nil ]
317
+ ScratchPad . recorded . should == [ nil , false , nil ]
318
+ @check . call . should == [ nil , false , nil ]
319
+
320
+ # undefined constant, CRuby 3.1 & 3.2 still do it here, but it is inconsistent, the constant should be removed
321
+ if ModuleSpecs ::Autoload . constants ( false ) . include? ( :RequiredDirectlyNoConstant )
322
+ @remove << :RequiredDirectlyNoConstant
323
+ end
321
324
end
322
325
end
323
326
0 commit comments