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 | 8802ebc9e1fa5bfe67aa0a5ae338b4194df0b732 (patch) | |
tree | 79bd91acc7809bb2980d6b0630fde68cde5a7d45 | |
parent | 7e932df0d519797535020a38f58da02bdb59c13c (diff) | |
download | ruby-8802ebc9e1fa5bfe67aa0a5ae338b4194df0b732.tar.gz |
* 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
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | test/inlinetest.rb | 23 |
2 files changed, 20 insertions, 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. diff --git a/test/inlinetest.rb b/test/inlinetest.rb index cd1ee0c683..8cc75da9c7 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 |