From: Gregory Brown Date: 2008-12-17T08:59:13+09:00 Subject: [ruby-core:20602] Quick question about zlib tests I'm working on backporting the zlib tests from Ruby 1.9.1 to Ruby 1.8.6, and just have a couple questions. (Currently working off of ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-darwin9.4.0] ) Here is my test file so far, which I've removed a small amount of 1.9.1isms from to get most of the tests to pass: http://pastie.org/340918 I've got it down to just three errors: 1) Error: test_params(TestZlibDeflate): Zlib::BufError: buffer error test_zlib.rb:130:in `inflate' test_zlib.rb:130:in `test_params' 2) Error: test_getbyte(TestZlibGzipReader): NoMethodError: undefined method `getbyte' for # test_zlib.rb:484:in `test_getbyte' test_zlib.rb:484:in `each_byte' test_zlib.rb:484:in `test_getbyte' 3) Error: test_readpartial(TestZlibGzipReader): NoMethodError: undefined method `readpartial' for # test_zlib.rb:458:in `test_readpartial' 55 tests, 380 assertions, 0 failures, 3 errors For 2 and 3, I assume these are just new features in Ruby 1.9.1? If so, I imagine I could safely remove them from the tests, but I wanted to make sure that they were just features that won't be in Ruby 1.8.6 and not that the tests themselves were having problems. If this is the case, please let me know. But 1) is a little more disturbing, as I'm not sure why it's happening. Here is the code of the failing test: def test_params z = Zlib::Deflate.new z << "foo" z.params(Zlib::DEFAULT_COMPRESSION, Zlib::DEFAULT_STRATEGY) z << "bar" s = z.finish assert_equal("foobar", Zlib::Inflate.inflate(s)) data = ('a'..'z').to_a.join z = Zlib::Deflate.new(Zlib::NO_COMPRESSION, Zlib::MAX_WBITS, Zlib::DEF_MEM_LEVEL, Zlib::DEFAULT_STRATEGY) z << data[0, 10] z.params(Zlib::BEST_COMPRESSION, Zlib::DEFAULT_STRATEGY) z << data[10 .. -1] assert_equal(data, Zlib::Inflate.inflate(z.finish)) z = Zlib::Deflate.new s = z.deflate("foo", Zlib::FULL_FLUSH) z.avail_out = 0 z.params(Zlib::NO_COMPRESSION, Zlib::FILTERED) s << z.deflate("bar", Zlib::FULL_FLUSH) z.avail_out = 0 z.params(Zlib::BEST_COMPRESSION, Zlib::HUFFMAN_ONLY) s << z.deflate("baz", Zlib::FINISH) assert_equal("foobarbaz", Zlib::Inflate.inflate(s)) z = Zlib::Deflate.new assert_raise(Zlib::StreamError) { z.params(10000, 10000) } z.close # without this, outputs `zlib(finalizer): the stream was freed prematurely.' end I am a total zlib n00b and this is my first time attempting to hack on anything in the Ruby core (if only the tests), so if there is something I'm missing such as an API change or other issue, please just let me know. But if it's a bug, I can drop it in the tracker. Once I figure out what to do with these three cases, I'll have a functioning backport of the comprehensive set of 1.9 tests to 1.8.6, which seems to ship with just a couple simple tests at the moment. I'd be happy to contribute this back, if the maintainers of Ruby 1.8.6 are interested. (My changes are extremely minimal) Anyway, if anyone know the answers to these questions, please let me know. -greg -- Technical Blaag at: http://blog.majesticseacreature.com Non-tech stuff at: http://metametta.blogspot.com "Ruby Best Practices" Book now in O'Reilly Roughcuts: http://rubybestpractices.com