mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test_autoload.rb: use class_eval
* test/ruby/test_autoload.rb (add_autoload): use class_eval instead of string eval. * test/ruby/test_autoload.rb (remove_autoload_constant): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
bd40bd3393
commit
058823440d
1 changed files with 2 additions and 10 deletions
|
@ -214,19 +214,11 @@ p Foo::Bar
|
||||||
|
|
||||||
def add_autoload(path)
|
def add_autoload(path)
|
||||||
(@autoload_paths ||= []) << path
|
(@autoload_paths ||= []) << path
|
||||||
eval <<-END
|
::Object.class_eval {autoload(:AutoloadTest, path)}
|
||||||
class ::Object
|
|
||||||
autoload :AutoloadTest, #{path.dump}
|
|
||||||
end
|
|
||||||
END
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_autoload_constant
|
def remove_autoload_constant
|
||||||
$".replace($" - @autoload_paths)
|
$".replace($" - @autoload_paths)
|
||||||
eval <<-END
|
::Object.class_eval {remove_const(:AutoloadTest)}
|
||||||
class ::Object
|
|
||||||
remove_const(:AutoloadTest)
|
|
||||||
end
|
|
||||||
END
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue