Sha256: 80cc173049f44b11a917120132e7b87f9bb4f8066b6b122971cf4ac68c1c5886

Contents?: true

Size: 365 Bytes

Versions: 4

Compression:

Stored size: 365 Bytes

Contents

# coding: utf-8
describe Integer, "#reciprocal" do
  
  100.times do
    n = rand(10**10)
    redo if n.zero?
    r = Rational(1, n)
    it "returns #{r} as the reciprocal of #{n}" do
      n.reciprocal.should == r
    end
  end

  it "raises a ZeroDivisionError for the reciprocal of zero" do
    ->{ 0.reciprocal }.should raise_error(ZeroDivisionError)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
numb-0.186.0 spec/numb/reciprocal_spec.rb
numb-0.185.0 spec/numb/reciprocal_spec.rb
numb-0.184.0 spec/numb/reciprocal_spec.rb
numb-0.181.0 spec/numb/reciprocal_spec.rb