« Previous -
Version 12/15
(diff) -
Next » -
Current version
Arthur Schreiber, 05/22/2008 09:03 AM
Bugs found while writing specs
Our policy of dealing with bugs found in MRI
- Ruby-Core must be notified
- Use #ruby_bug guard for the spec code that breaks due to MRI bug
- Add the bug to this page below
- MRI specific bug should be filed (optional, but highly desirable)
Bugs in the Complex library
Incompatible changes to the Math module
Complex modifies the Math library in a way that breaks compatibility in many ways.
1 Math.log("10") # => 2.30258509299405
2 require "complex"
3 Math.log("10") # => raises NoMethodError: undefined method `polar' for "10":String
Running the Math specs after the Complex specs, exposes a total of 50 errors/failures.
bin/mspec -t r spec/ruby/1.8/library/complex/ spec/ruby/1.8/core/math/ ... 77 files, 433 examples, 977 expectations, 33 failures, 17 errors
See the attached complex_math.patch file for fixes.
Some of Complex' methods fail when the Complex contains Floats
1 require "complex"
2 Complex(3, 4).numerator # => Complex(3, 4)
3 Complex(3.6, 3).numerator # => raises NoMethodError: undefined method `denominator' for 3.6:Float
I think it would be more appropriate to raise a "real" exception.
Complex#hash might cause problems
1 require "complex"
2 Complex(3, 4).hash # => 14
3 Complex(4, 3).hash # => 14
Bugs in the Rational library
Rational#hash might cause problems
1 require "rational"
2 Rational(3, 4).hash # => 14
3 Rational(4, 3).hash # => 14
Rational#initialize
Rational#initialize seems to be intended to allow passing of Strings and other types (Duck-Typed Integers) (due to the conversion using #to_i if the given arguments are not Integers), but this does not work because of the checks whether the denominator is positive or negative.
1 require "rational"
2 Rational("3", "4") # => raises "ArgumentError: comparison of String with 0 failed"
