Sha256: 7df237e7ba33f1608f253b2ad4733ddfdb596bfafa48e0c26506faace4492459
Contents?: true
Size: 790 Bytes
Versions: 1
Compression:
Stored size: 790 Bytes
Contents
require 'spec_helper' sum_expectations = { [] => 0, # see http://en.wikipedia.org/wiki/Empty_sum [1] => 1, [1.0] => 1.0, [1, -1] => 0, [1, 2, 3] => 6, [1, 2, 3.0] => 6.0, (0...0) => 0, # see http://en.wikipedia.org/wiki/Empty_sum (1..1) => 1, (0..3) => 6, [BigDecimal("0.0")] => BigDecimal("0.0"), [3, BigDecimal("1.0")] => BigDecimal("4.0") } describe Enumerable do describe "#sum" do sum_expectations.each do |data, expected| it "is #{expected.inspect} for #{data.inspect}" do sum = data.sum sum.should == expected sum.class.should == expected.class end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
simple_stats-1.0.0 | spec/enumerable/sum_spec.rb |