diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-01-14 08:54:21 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-01-14 08:54:21 +0000 |
| commit | 1e0262d9620de936d2866956834ffc2c34374f8f (patch) | |
| tree | 79bd91acc7809bb2980d6b0630fde68cde5a7d45 /test | |
| parent | 476fc48db01f8a931e61a88917bdf2797f991bc5 (diff) | |
| download | ruby-1e0262d9620de936d2866956834ffc2c34374f8f.tar.gz ruby-1e0262d9620de936d2866956834ffc2c34374f8f.tar.xz ruby-1e0262d9620de936d2866956834ffc2c34374f8f.zip | |
* test/inlinetest.rb (InlineTest::loadtest): require instead of
load, to get rid of multiple loading.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@5463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
| -rw-r--r-- | test/inlinetest.rb | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/test/inlinetest.rb b/test/inlinetest.rb index cd1ee0c68..8cc75da9c 100644 --- a/test/inlinetest.rb +++ b/test/inlinetest.rb @@ -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 |
