* lib/csv.rb: A fix for row comparison by Stephen Wattam. [Bug #7528]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0dc6b83935
commit
5b1065f3fe
@ -1,3 +1,7 @@
|
|||||||
|
Tue Dec 08 02:39:23 2012 James Edward Gray II <james@graysoftinc.com>
|
||||||
|
|
||||||
|
* lib/csv.rb: A fix for row comparison by Stephen Wattam. [Bug #7528]
|
||||||
|
|
||||||
Sat Dec 8 01:27:23 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Dec 8 01:27:23 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* lib/test/unit.rb (Test::Unit::Runner#_run_parallel): no need to
|
* lib/test/unit.rb (Test::Unit::Runner#_run_parallel): no need to
|
||||||
|
@ -475,7 +475,8 @@ class CSV
|
|||||||
# same order as +other+.
|
# same order as +other+.
|
||||||
#
|
#
|
||||||
def ==(other)
|
def ==(other)
|
||||||
@row == other.row
|
return @row == other.row if other.is_a? CSV::Row
|
||||||
|
@row == other
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -256,7 +256,7 @@ class TestCSV::Row < TestCSV
|
|||||||
assert_equal( [["A", 1], ["A", 4], ["A", nil]],
|
assert_equal( [["A", 1], ["A", 4], ["A", nil]],
|
||||||
@row.select { |pair| pair.first == "A" } )
|
@row.select { |pair| pair.first == "A" } )
|
||||||
|
|
||||||
assert_equal(10, @row.inject(0) { |sum, (header, n)| sum + (n || 0) })
|
assert_equal(10, @row.inject(0) { |sum, (_, n)| sum + (n || 0) })
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_to_a
|
def test_to_a
|
||||||
@ -310,4 +310,8 @@ class TestCSV::Row < TestCSV
|
|||||||
"Header field pair not found." )
|
"Header field pair not found." )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_can_be_compared_with_other_classes
|
||||||
|
assert(CSV::Row.new([ ], [ ]) != nil, "The row was nil")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user