1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* test/inlinetest.rb (InlineTest::loadtest): requiring library with

replaced $0 can make $0 == __FILE__ block be evaluated twice.
  [ruby-dev:23538]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2004-05-19 09:00:48 +00:00
parent 3ac7b642fa
commit c504ca6776
2 changed files with 15 additions and 8 deletions

View file

@ -1,6 +1,12 @@
Wed May 19 18:00:44 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* test/inlinetest.rb (InlineTest::loadtest): requiring library with
replaced $0 can make $0 == __FILE__ block be evaluated twice.
[ruby-dev:23538]
Wed May 19 11:08:10 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> Wed May 19 11:08:10 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk.rb: change permition of TkObject#tk_send from * ext/tk/lib/tk.rb: change permition of TkObject#tk_send from
private to public private to public
Wed May 19 02:29:36 2004 Minero Aoki <aamine@loveruby.net> Wed May 19 02:29:36 2004 Minero Aoki <aamine@loveruby.net>
@ -25,26 +31,26 @@ Tue May 18 21:21:43 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
* CSV::Cell removed. a cell is represented as just a String or * CSV::Cell removed. a cell is represented as just a String or
nil(NULL). this change will cause widespread destruction. nil(NULL). this change will cause widespread destruction.
CSV.open("foo.csv", "r") do |row| CSV.open("foo.csv", "r") do |row|
row.each do |cell| row.each do |cell|
if cell.is_null # Cell#is_null if cell.is_null # Cell#is_null
p "(NULL)" p "(NULL)"
else else
p cell.data # Cell#data p cell.data # Cell#data
end end
end end
end end
must be just; must be just;
CSV.open("foo.csv", "r") do |row| CSV.open("foo.csv", "r") do |row|
row.each do |cell| row.each do |cell|
if cell.nil? if cell.nil?
p "(NULL)" p "(NULL)"
else else
p cell p cell
end end
end end
end end
* lib/csv.rb: [CAUTION] record separator(CR, LF, CR+LF) behavior * lib/csv.rb: [CAUTION] record separator(CR, LF, CR+LF) behavior
@ -55,7 +61,7 @@ Tue May 18 21:21:43 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
parameter "r", "w", "rb", and "wb". CSV.parse and CSV.generate open parameter "r", "w", "rb", and "wb". CSV.parse and CSV.generate open
file with "r" and "w". file with "r" and "w".
setting mode properly is user's responsibility now. setting mode properly is user's responsibility now.
* lib/csv.rb: accepts String as a fs (field separator/column separator) * lib/csv.rb: accepts String as a fs (field separator/column separator)
and rs (record separator/row separator) and rs (record separator/row separator)

View file

@ -6,12 +6,12 @@ module InlineTest
if endpart.nil? if endpart.nil?
raise RuntimeError.new("No #{part} part in the library '#{filename}'") raise RuntimeError.new("No #{part} part in the library '#{filename}'")
end end
require(libname)
eval(endpart, TOPLEVEL_BINDING, path, mainpart.count("\n")+1) eval(endpart, TOPLEVEL_BINDING, path, mainpart.count("\n")+1)
end end
module_function :eval_part module_function :eval_part
def loadtest(libname) def loadtest(libname)
require(libname)
in_critical do in_critical do
in_progname(libpath(libname)) do in_progname(libpath(libname)) do
eval_part(libname, /^(?=if\s+(?:\$0\s*==\s*__FILE__|__FILE__\s*==\s*\$0)(?:[\#\s]|$))/, '$0 == __FILE__') eval_part(libname, /^(?=if\s+(?:\$0\s*==\s*__FILE__|__FILE__\s*==\s*\$0)(?:[\#\s]|$))/, '$0 == __FILE__')
@ -21,6 +21,7 @@ module InlineTest
module_function :loadtest module_function :loadtest
def loadtest__END__part(libname) def loadtest__END__part(libname)
require(libname)
eval_part(libname, /^__END__$/, '__END__') eval_part(libname, /^__END__$/, '__END__')
end end
module_function :loadtest__END__part module_function :loadtest__END__part