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

Fixed regression to convert blank value at r45497.

[Bug #11126][ruby-core:69088]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
hsbt 2017-08-22 06:57:00 +00:00
parent ede0df3a9b
commit ffb49a7e9b
2 changed files with 10 additions and 1 deletions

View file

@ -2207,7 +2207,7 @@ class CSV
fields.map.with_index do |field, index|
converters.each do |converter|
break if field.nil?
break if headers && field.nil?
field = if converter.arity == 1 # straight field converter
converter[field]
else # FieldInfo converter

View file

@ -176,6 +176,15 @@ class TestCSV::DataConverters < TestCSV
@parser.shift.fields )
end
def test_custom_converter_with_blank_field
converter = lambda { |field| field.nil? }
row = nil
assert_nothing_raised(Exception) do
row = CSV.parse_line('nil,', converters: converter)
end
assert_equal([false, true], row);
end
def test_shortcut_interface
assert_equal( ["Numbers", ":integer", 1, ":float", 3.015],
CSV.parse_line(@data, converters: :numeric) )