зеркало из https://github.com/github/ruby.git
* lib/csv.rb: Do not modify CSV.generate's argument [ruby-core:38356]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32600 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
272322bede
Коммит
616cae1090
|
@ -1,3 +1,7 @@
|
|||
Fri Jul 22 06:37:13 2011 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||
|
||||
* lib/csv.rb: Do not modify CSV.generate's argument [ruby-core:38356]
|
||||
|
||||
Thu Jul 21 20:59:59 2011 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/ancdata.c (discard_cmsg): workaround for MacOS X Lion.
|
||||
|
|
|
@ -1234,7 +1234,7 @@ class CSV
|
|||
io.seek(0, IO::SEEK_END)
|
||||
args.unshift(io)
|
||||
else
|
||||
encoding = args.last.is_a?(Hash) ? args.last.delete(:encoding) : nil
|
||||
encoding = (args[-1] = args[-1].dup).delete(:encoding) if args.last.is_a?(Hash)
|
||||
str = ""
|
||||
str.encode!(encoding) if encoding
|
||||
args.unshift(str)
|
||||
|
|
|
@ -316,4 +316,19 @@ class TestCSV::Interface < TestCSV
|
|||
assert_equal(STDOUT, CSV.instance.instance_eval { @io })
|
||||
assert_equal(STDOUT, CSV { |new_csv| new_csv.instance_eval { @io } })
|
||||
end
|
||||
|
||||
def test_options_are_not_modified
|
||||
opt = {}.freeze
|
||||
assert_nothing_raised { CSV.foreach(@path, opt) }
|
||||
assert_nothing_raised { CSV.open(@path, opt){} }
|
||||
assert_nothing_raised { CSV.parse("", opt) }
|
||||
assert_nothing_raised { CSV.parse_line("", opt) }
|
||||
assert_nothing_raised { CSV.read(@path, opt) }
|
||||
assert_nothing_raised { CSV.readlines(@path, opt) }
|
||||
assert_nothing_raised { CSV.table(@path, opt) }
|
||||
assert_nothing_raised { CSV.generate(opt){} }
|
||||
assert_nothing_raised { CSV.generate_line([], opt) }
|
||||
assert_nothing_raised { CSV.filter("", "", opt){} }
|
||||
assert_nothing_raised { CSV.instance("", opt) }
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче