Bugs found while writing specs
Version 14 (Arthur Schreiber, 05/29/2008 03:03 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 | |
| 61 | 14 | Arthur Schreiber | |
| 62 | 14 | Arthur Schreiber | h2. Bugs in the Net::FTP library |
| 63 | 14 | Arthur Schreiber | |
| 64 | 14 | Arthur Schreiber | h3. A response code of type 5xx when calling Net::FTP#chdir results in a NoMethodError. |
| 65 | 14 | Arthur Schreiber | |
| 66 | 14 | Arthur Schreiber | The offending line is in net/ftp.rb at line 671: |
| 67 | 14 | Arthur Schreiber | |
| 68 | 14 | Arthur Schreiber | |
| 69 | 14 | Arthur Schreiber | if $![0, 3] != "500" |
| 70 | 14 | Arthur Schreiber | |
| 71 | 14 | Arthur Schreiber | |
| 72 | 14 | Arthur Schreiber | Exceptions do not respond to the method #[], thus this line results in a NoMethodError. |
| 73 | 14 | Arthur Schreiber | |
| 74 | 14 | Arthur Schreiber | A fix for this problem is to change the line to: |
| 75 | 14 | Arthur Schreiber | |
| 76 | 14 | Arthur Schreiber | |
| 77 | 14 | Arthur Schreiber | if $!.message[0, 3] != "500" |
| 78 | 14 | Arthur Schreiber |
