Mind Ramblings My Blog

Arithmetic Test Cases

Hey there! This week I implemented the suggestions given after the first round of review for PR#487 and I tried to port the test cases in test_arit.py to arit_spec.rb. It was worth it! The unit tests that I had written for the individual classes were not enough and didn’t cover every situation where an error might occur. Many test cases failed, indicating I had failed to include a corner case. After finding and fixing them, most of the cases passed except a few. They are

......FF..............................

Failures:

  1) Arithmetic test cases test_arit7
     Failure/Error: assert 2 * x - x == x
     TypeError:
       wrong argument type Fixnum (expected Class)
     # ./spec/arit_spec.rb:80:in `-'
     # ./spec/arit_spec.rb:80:in `block (2 levels) in <top (required)>'

  2) Arithmetic test cases test_arit8
     Failure/Error: assert x**2 / x == x
     TypeError:
       wrong argument type Fixnum (expected Class)
     # ./spec/arit_spec.rb:94:in `/'
     # ./spec/arit_spec.rb:94:in `block (2 levels) in <top (required)>'

Finished in 0.01956 seconds (files took 0.10097 seconds to load)
38 examples, 2 failures

Failed examples:

rspec ./spec/arit_spec.rb:75 # Arithmetic test cases test_arit7
rspec ./spec/arit_spec.rb:86 # Arithmetic test cases test_arit8

The error messages show that the argument type to - and / are Fixnum. And the error messages don’t even make sense. It can be clearly seen that the operand to - and / are SymEngine::Symbols. I had even tried printing them out, just to be double sure. I am not able to figure out what might be the reason. Any help will be really appreciated.

And there are still a few bugs in sympify, the function that takes a ruby object and returns the corresponding C structure for the type.

Next Week

I know I again failed my this weeks target. There are just too many tests these companies(they are in our university to select interns) are taking and there are assignments on top of that. I did what I could.

My next week’s target is to document everything I have done so far, including the beginner contributor guide. I know the pain of going through undocumented code, and I don’t want to turn away someone interested who has come to read my code.

And it is obvious that the problems faced in getting the PR#487, will be resolved by then, and sent for feedback. I am yet to confirm if we will be hosting the gem on RubyGems.org by then.

Commits

  • Moved module and class declarations to symengine.h
  • Removed modifications of Fixnum and Bignum
  • Added method sympify & modified GET_SYMINTFROMVAL
  • Implemented class coercion. Integer and Rational can now be coerced into SymEngine classes
  • Updated test for large number
  • Added coercion tests for Integer
  • Added coercion tests for Rational
  • Used sympify in == and !=
  • Added arit_spec.rb, rspec equivalent of test_arit.py


comments powered by Disqus