David Brady wrote: > Levin Alexander wrote: > > > require 'enumerator' > > cal_lines = cal.to_html.to_enum(:each_line).to_a > > > > > Innnteresting. This condenses the loop initialization into a single > line... but it's pretty hairy: > > > @html_reference.to_enum(:each_line).zip(cal.to_html.to_enum(:each_line)).each_with_index > do |test_line, line_no| > assert_equal( test_line[0], test_line[1], "Calendar#to_html > incorrect on line #{line_no+1}") > end > > I don't think we've really cleaned much up, though. We've moved from > C++ pooping Ruby's pants to Ruby pooping its own pants. It's idiomatic, > but we haven't reached elegance yet. class Array # The differences between 2 arrays of equal size. def dif( other ) ( (0...self.size).to_a.zip( self ) - (0...self.size).to_a.zip( other ) ).map{|x| x<<other[x[0]] } end end @html_reference.to_enum(:each_line).dif( cal.to_html.to_enum(:each_line) ).each{ |x| # Line numbering starts with 1. x[0] += 1 print "Incorrect at line "; puts x; puts }