Bugs found while writing specs

Version 13 (Arthur Schreiber, 05/22/2008 09:05 AM)

1 1
h1. Bugs found while writing specs
2 1
3 2 Vladimir Sizikov
h2. Our policy of dealing with bugs found in MRI
4 2 Vladimir Sizikov
5 2 Vladimir Sizikov
* Ruby-Core must be notified
6 2 Vladimir Sizikov
* Use #ruby_bug guard for the spec code that breaks due to MRI bug
7 2 Vladimir Sizikov
* Add the bug to this page below
8 2 Vladimir Sizikov
* MRI specific bug should be filed (optional, but highly desirable)
9 2 Vladimir Sizikov
10 1
h2. Bugs in the Complex library
11 1
12 3 Arthur Schreiber
h3. Incompatible changes to the Math module
13 3 Arthur Schreiber
14 1
Complex modifies the Math library in a way that breaks compatibility in many ways.
15 1
16 1
17 1
  Math.log("10") # => 2.30258509299405
18 1
  require "complex"
19 1
  Math.log("10") # => raises NoMethodError: undefined method `polar' for "10":String
20 1
21 1
22 5 Arthur Schreiber
Running the Math specs after the Complex specs, exposes a total of *50 errors/failures*.
23 1
24 1
25 1
bin/mspec -t r spec/ruby/1.8/library/complex/ spec/ruby/1.8/core/math/
26 1
27 1
...
28 1
29 5 Arthur Schreiber
77 files, 433 examples, 977 expectations, 33 failures, 17 errors
30 1
31 4 Arthur Schreiber
32 8 Arthur Schreiber
See the attached complex_math.patch file for fixes.
33 6 Arthur Schreiber
34 9 Arthur Schreiber
h3. Some of Complex' methods fail when the Complex contains Floats
35 1
36 9 Arthur Schreiber
37 9 Arthur Schreiber
  require "complex"
38 9 Arthur Schreiber
  Complex(3, 4).numerator # => Complex(3, 4)
39 9 Arthur Schreiber
  Complex(3.6, 3).numerator # => raises NoMethodError: undefined method `denominator' for 3.6:Float
40 9 Arthur Schreiber
41 9 Arthur Schreiber
42 9 Arthur Schreiber
I think it would be more appropriate to raise a "real" exception.
43 10 Arthur Schreiber
44 10 Arthur Schreiber
h3. Complex#hash might cause problems
45 10 Arthur Schreiber
46 10 Arthur Schreiber
47 10 Arthur Schreiber
  require "complex"
48 10 Arthur Schreiber
  Complex(3, 4).hash # => 14
49 10 Arthur Schreiber
  Complex(4, 3).hash # => 14
50 10 Arthur Schreiber
51 11 Arthur Schreiber
52 11 Arthur Schreiber
h2. Bugs in the Rational library
53 11 Arthur Schreiber
54 11 Arthur Schreiber
h3. Rational#hash might cause problems
55 11 Arthur Schreiber
56 11 Arthur Schreiber
57 11 Arthur Schreiber
  require "rational"
58 11 Arthur Schreiber
  Rational(3, 4).hash # => 14
59 11 Arthur Schreiber
  Rational(4, 3).hash # => 14
60 11 Arthur Schreiber