Sha256: 129edc0602b342524f6ef33ce80f024feda400531e476fae88a1532026f8c6b5

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

frequencies_expectations = {
  []                       => {},
  [1]                      => { 1 => 1 },
  [1.0]                    => { 1.0 => 1 },
  [1, -1]                  => { -1 => 1, 1 => 1 },
  [3, 1, 3]                => { 3 => 2, 1 => 1 },
  [3, 1, 3.0]              => { 3 => 2, 1 => 1 },
  [3.0, 1, 3]              => { 3.0 => 2, 1 => 1 },
  (0...0)                  => {},
  (1..1)                   => { 1 => 1 },
  (0..3)                   => { 0 => 1, 1 => 1, 2 => 1, 3 => 1 },
  [BigDecimal("0.0")]      => { BigDecimal("0.0") => 1 },
  [-2, BigDecimal("1.0")]  => { -2 => 1, BigDecimal("1.0") => 1 },
  [:b, :c, :b, :c, :c, :a] => { :c => 3, :b => 2, :a => 1 }
}

describe Enumerable do
  describe "#frequencies" do
    frequencies_expectations.each do |data, expected|
      it "is #{expected.inspect} for #{data.inspect}" do
        frequencies = data.frequencies
        frequencies.should       == expected
        frequencies.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/frequencies_spec.rb