From: z4k4ri4@... (Zakaria) Date: 2002-01-11T14:03:50+09:00 Subject: (DBI || RUnit || Ruby || My_Understanding).bug? Hi Rubyers Is it a bug or not? If it is then whoose? The script: --------------------------------------------------------------------- #!/usr/bin/ruby require 'dbi' require 'runit/testcase' module DBI class Date def ==(other) return @year == other.year && @month == other.month && @day == other.day end end end result = DBI.connect('DBI:Pg:test', 'rumah') {|dbh| dbh.select_all "select * from date_test where id=45 order by id" } expected = [[45, DBI::Date.new(2002, 7, 25)]] p result p expected puts(result == expected) # => true puts(result != expected) # => false class SQLTest < RUNIT::TestCase def setup @db = DBI.connect('DBI:Pg:test', 'rumah') end def tear_down @db.disconnect end def op_test(expr, expected) actual = @db.select_all \ "select * from date_test where #{expr} order by id" #actual = [[45, DBI::Date.new(2002, 7, 25)]] # This works #assert(expected == actual, expr) # Also fail assert_equal(expected, actual, expr) end def test_one expected = [[45, DBI::Date.new(2002, 7, 25)]] op_test('id = 45', expected) end end #--- main program ---- if __FILE__ == $0 require 'runit/cui/testrunner' suite = SQLTest.suite RUNIT::CUI::TestRunner.run(suite) end --------------------------------------------------------------------- The output on LM 8.1 --------------------------------------------------------------------- [zakaria@hamdalah ruby]$ ruby -v ruby 1.6.4 (2001-06-04) [i586-linux-gnu] [zakaria@hamdalah ruby]$ ./sql.rb [[45, #]] [[45, #]] true false SQLTest#test_one F. Time: 0.130027 FAILURES!!! Test Results: Run: 1/1(1 asserts) Failures: 1 Errors: 0 Failures: 1 ../sql.rb:35:in `op_test'(SQLTest): id = 45 expected:<[[45, #]]> but was:<[[45, #]]> (RUNIT::AssertionFailedError) from ./sql.rb:39:in `test_one' from ./sql.rb:46 --------------------------------------------------------------------- The output on Cygwin --------------------------------------------------------------------- $ ruby -v ruby 1.6.5 (2001-09-19) [i686-cygwin] $ ./sql.rb [[45, #]] [[45, #]] true false SQLTest#test_one F. Time: 0.5 FAILURES!!! Test Results: Run: 1/1(1 asserts) Failures: 1 Errors: 0 Failures: 1 ../sql.rb:35:in `op_test'(SQLTest): id = 45 expected:<[[45, #]]> but was:<[[45, #]]> (RUNIT::AssertionFailedError) from ./sql.rb:39:in `test_one' from ./sql.rb:46 ---------------------------------------------------------------------