Sha256: a24561aee2769d133834572bc3c14b1befeadee7e3695f4933a6dd074a1c1196

Contents?: true

Size: 700 Bytes

Versions: 24

Compression:

Stored size: 700 Bytes

Contents

require 'spec_helper'

describe Internals::Generators::Weights::Logarithmic do

  before(:each) do
    @cacher = described_class.new
  end

  describe 'generate_from' do
    it 'should not fail on empties' do
      @cacher.generate_from({ :key => [] }).should == { :key => 0 }
    end
    it 'should round to 2' do
      @cacher.generate_from({ :key => [1,2,3,4] }).should == { :key => 1.39 }
    end
  end

  describe 'weight_for' do
    it 'should be 0 for 0' do
      @cacher.weight_for(0).should == 0
    end
    it 'should be 0 for 1' do
      @cacher.weight_for(1).should == 0
    end
    it 'should be log(x) for x' do
      @cacher.weight_for(1234).should == Math.log(1234)
    end
  end

end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
picky-2.5.2 spec/lib/internals/generators/weights/logarithmic_spec.rb
picky-2.5.1 spec/lib/internals/generators/weights/logarithmic_spec.rb
picky-2.5.0 spec/lib/internals/generators/weights/logarithmic_spec.rb
picky-2.4.3 spec/lib/internals/generators/weights/logarithmic_spec.rb
picky-2.4.2 spec/lib/internals/generators/weights/logarithmic_spec.rb
picky-2.4.1 spec/lib/internals/generators/weights/logarithmic_spec.rb
picky-2.4.0 spec/lib/internals/generators/weights/logarithmic_spec.rb
picky-2.3.0 spec/lib/internals/generators/weights/logarithmic_spec.rb
picky-2.2.1 spec/lib/internals/generators/weights/logarithmic_spec.rb
picky-2.2.0 spec/lib/internals/generators/weights/logarithmic_spec.rb
picky-2.1.2 spec/lib/internals/generators/weights/logarithmic_spec.rb
picky-2.1.1 spec/lib/internals/generators/weights/logarithmic_spec.rb
picky-2.1.0 spec/lib/internals/generators/weights/logarithmic_spec.rb
picky-2.0.0 spec/lib/internals/generators/weights/logarithmic_spec.rb
picky-2.0.0.pre3 spec/lib/internals/generators/weights/logarithmic_spec.rb
picky-2.0.0.pre2 spec/lib/internals/generators/weights/logarithmic_spec.rb
picky-2.0.0.pre1 spec/lib/internals/generators/weights/logarithmic_spec.rb
picky-1.5.4 spec/lib/internals/generators/weights/logarithmic_spec.rb
picky-1.5.3 spec/lib/internals/generators/weights/logarithmic_spec.rb
picky-1.5.2 spec/lib/internals/generators/weights/logarithmic_spec.rb