[MacRuby-devel] Porting Rational

Laurent Sansonetti lsansonetti at apple.com
Wed Jul 29 22:13:05 PDT 2009


Hi Dan,

Thanks a lot for your patch! I committed it as well as a few  
adjustments.

If I remove all tags from the complex and rational specs, we do have  
11 failures vs 455 expectations, which is a huge progress!

Might be interesting to investigate these failing specs. I suspect  
some of them have not been ported to Ruby 1.9 yet.

$ rm spec/frozen/tags/macruby/core/complex/*.txt
$ rm spec/frozen/tags/macruby/core/rational/*.txt
$ ./miniruby -I./lib ./mspec/bin/mspec-ci -B ./spec/macruby.mspec spec/ 
frozen/core/rational spec/frozen/core/complex
.FF 
..........................................F 
............F.F 
...................................................F 
.........EEE......................

1)
Rational() passed two arguments sets the numerator to the first  
argument FAILED
Expected 136053744742862656 to equal 362809985980967168
0:in `fail:'
0:in `fail_with:'
0:in `==:'
0:in `each'
0:in `protect:'
0:in `each'
0:in `all?'
0:in `protect:'
0:in `each'
0:in `process'
0:in `describe:'
0:in `context:'
0:in `ruby_version_is:'
0:in `load:'
0:in `protect:'
0:in `each'
0:in `files'
0:in `process'
0:in `run'

2)
Rational() passed two arguments sets the denominator to the second  
argument FAILED
Expected 990791918021509 to equal 2642111781390691
0:in `fail:'
0:in `fail_with:'
0:in `==:'
0:in `each'
0:in `protect:'
0:in `each'
0:in `all?'
0:in `protect:'
0:in `each'
0:in `process'
0:in `describe:'
0:in `context:'
0:in `ruby_version_is:'
0:in `load:'
0:in `protect:'
0:in `each'
0:in `files'
0:in `process'
0:in `run'

3)
Rational#divmod when passed an Integer returns the quotient as Integer  
and the remainder as Rational FAILED
Expected [768614336404564480, (512/1)] to equal [768614336404564650,  
(2/1)]
0:in `fail:'
0:in `fail_with:'
0:in `==:'
0:in `protect:'
0:in `each'
0:in `all?'
0:in `protect:'
0:in `each'
0:in `process'
0:in `describe:'
0:in `context:'
0:in `ruby_version_is:'
0:in `load:'
0:in `protect:'
0:in `each'
0:in `files'
0:in `process'
0:in `run'

4)
Rational#** when passed Rational returns a complex number when self is  
negative and the passed argument is not 0 FAILED
Expected NaN to equal (-0.733761610865473+1.27091239066258i)
0:in `fail:'
0:in `fail_with:'
0:in `==:'
0:in `protect:'
0:in `each'
0:in `all?'
0:in `protect:'
0:in `each'
0:in `process'
0:in `describe:'
0:in `context:'
0:in `ruby_version_is:'
0:in `load:'
0:in `protect:'
0:in `each'
0:in `files'
0:in `process'
0:in `run'

5)
Rational#** when passed Float returns a complex number if self is  
negative and the passed argument is not 0 FAILED
Expected NaN to equal (-3.3746182904644e-16-1.83711730708738i)
0:in `fail:'
0:in `fail_with:'
0:in `==:'
0:in `protect:'
0:in `each'
0:in `all?'
0:in `protect:'
0:in `each'
0:in `process'
0:in `describe:'
0:in `context:'
0:in `ruby_version_is:'
0:in `load:'
0:in `protect:'
0:in `each'
0:in `files'
0:in `process'
0:in `run'

6)
Complex#/ with Float raises a ZeroDivisionError when given 0.0 FAILED
Expected ZeroDivisionError but no exception was raised
0:in `fail:'
0:in `fail_with:'
0:in `should'

7)
Complex#% with Complex returns the remainder from complex division ERROR
NoMethodError: undefined method `div' for (13+44i):Complex
0:in `modulo:'
0:in `protect:'
0:in `each'
0:in `all?'
0:in `protect:'
0:in `each'
0:in `process'
0:in `describe:'
0:in `context:'
0:in `ruby_version_is:'
0:in `load:'
0:in `protect:'
0:in `each'
0:in `files'
0:in `process'
0:in `run'

8)
Complex#% with Integer returns the remainder from dividing both parts  
of self by the given Integer ERROR
NoMethodError: undefined method `div' for (21+42i):Complex
0:in `modulo:'
0:in `protect:'
0:in `each'
0:in `all?'
0:in `protect:'
0:in `each'
0:in `process'
0:in `describe:'
0:in `context:'
0:in `ruby_version_is:'
0:in `load:'
0:in `protect:'
0:in `each'
0:in `files'
0:in `process'
0:in `run'

9)
Complex#% with Object tries to coerce self into other ERROR
NoMethodError: undefined method `div' for (3+9i):Complex
0:in `modulo:'
0:in `protect:'
0:in `each'
0:in `all?'
0:in `protect:'
0:in `each'
0:in `process'
0:in `describe:'
0:in `context:'
0:in `ruby_version_is:'
0:in `load:'
0:in `protect:'
0:in `each'
0:in `files'
0:in `process'
0:in `run'

10)
An exception occurred during: Mock.verify_count
Complex#% with Object tries to coerce self into other FAILED
Mock 'Object' expected to receive 'coerce' exactly 1 times
but received it 0 times
0:in `fail:'
0:in `fail_with:'

Finished in 2.661908 seconds

49 files, 142 examples, 455 expectations, 7 failures, 3 errors

Laurent

On Jul 29, 2009, at 9:31 PM, dan sinclair wrote:

> As requested I grabbed the latest rational.c and complex.c from ruby  
> SVN and got them working under MacRuby. Patch is attached.
>
> dan
>
> <rational_complex_2.diff.gz>
>
>
>
>
> On Jul 28, 2009, at 11:54 PM, dan sinclair wrote:
>
>> Hello,
>>
>> I started to port the Rational code to the objc interfaces.  There  
>> are currently 8 specs left for rational that I haven't been able to  
>> get to pass. As part of the rational I also did a bit of the  
>> Complex code but there are some specs in there that are segv'ing so  
>> I'm not sure how many of those pass at the moment.
>>
>> Patch is attached. Let me know if I need to fix anything up.
>>
>> Thanks,
>> dan
>>
>> (I would have logged this into trac but I can't seem to login at  
>> the moment. Continuously redirects between http://www.macruby.org/auth/login 
>>  and https://www.macruby.org/auth/login)
>>
>> <rational_complex_1.diff>
>> _______________________________________________
>> MacRuby-devel mailing list
>> MacRuby-devel at lists.macosforge.org
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel



More information about the MacRuby-devel mailing list