diff options
Diffstat (limited to 'spec/ruby/core/numeric/modulo_spec.rb')
| -rw-r--r-- | spec/ruby/core/numeric/modulo_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/ruby/core/numeric/modulo_spec.rb b/spec/ruby/core/numeric/modulo_spec.rb new file mode 100644 index 0000000000..0baf96dc18 --- /dev/null +++ b/spec/ruby/core/numeric/modulo_spec.rb @@ -0,0 +1,21 @@ +require_relative '../../spec_helper' + +describe "Numeric#modulo" do + it "is an alias of Numeric#%" do + Numeric.instance_method(:modulo).should == Numeric.instance_method(:%) + end +end + +describe "Numeric#%" do + it "returns self - other * self.div(other)" do + s = mock_numeric('self') + o = mock_numeric('other') + n3 = mock_numeric('n3') + n4 = mock_numeric('n4') + n5 = mock_numeric('n5') + s.should_receive(:div).with(o).and_return(n3) + o.should_receive(:*).with(n3).and_return(n4) + s.should_receive(:-).with(n4).and_return(n5) + (s % o).should == n5 + end +end |
