mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/inlinetest.rb (InlineTest::loadtest): require instead of
load, to get rid of multiple loading. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7e932df0d5
commit
8802ebc9e1
2 changed files with 20 additions and 8 deletions
|
@ -1,3 +1,8 @@
|
|||
Wed Jan 14 17:54:17 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* test/inlinetest.rb (InlineTest::loadtest): require instead of
|
||||
load, to get rid of multiple loading.
|
||||
|
||||
Wed Jan 14 13:30:52 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/iconv/extconf.rb: wrapper iconv.rb is dependent on platform.
|
||||
|
|
|
@ -1,21 +1,28 @@
|
|||
module InlineTest
|
||||
def eval_part(libname, sep, part)
|
||||
path = libpath(libname)
|
||||
program = File.open(path) { |f| f.read }
|
||||
mainpart, endpart = program.split(sep)
|
||||
if endpart.nil?
|
||||
raise RuntimeError.new("No #{part} part in the library '#{filename}'")
|
||||
end
|
||||
require(libname)
|
||||
eval(endpart, nil, path, mainpart.count("\n")+1)
|
||||
end
|
||||
module_function :eval_part
|
||||
|
||||
def loadtest(libname)
|
||||
Kernel.require(libname)
|
||||
in_critical do
|
||||
in_progname(libpath(libname)) do
|
||||
Kernel.load(libname)
|
||||
eval_part(libname, /^(?=if\s+(?:\$0\s*==\s*__FILE__|__FILE__\s*==\s*\$0)(?:[\#\s]|$))/, '$0 == __FILE__')
|
||||
end
|
||||
end
|
||||
end
|
||||
module_function :loadtest
|
||||
|
||||
def loadtest__END__part(libname)
|
||||
program = File.open(libpath(libname)) { |f| f.read }
|
||||
mainpart, endpart = program.split(/^__END__$/)
|
||||
if endpart.nil?
|
||||
raise RuntimeError.new("No __END__ part in the library '#{filename}'")
|
||||
end
|
||||
require(libname)
|
||||
eval(endpart)
|
||||
eval_part(libname, /^__END__$/, '__END__')
|
||||
end
|
||||
module_function :loadtest__END__part
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue