Sha256: bab7e4a55a73ef3109a476b211dd154c7c691994857cb2a965d7150ee7de5543

Contents?: true

Size: 663 Bytes

Versions: 36

Compression:

Stored size: 663 Bytes

Contents

describe Integer, "#self_descriptive?" do
  SELF_DESCRIPTIVE = [nil,nil,nil,nil,1210,21200,nil,
                      3211000,42101000,521001000,6210001000]
  
  SELF_DESCRIPTIVE.each_with_index do |number, base|
    next if number.nil?
    it "returns true if the number is self-descriptive in base #{base}" do
      number.self_descriptive?(base).should be_true
    end
  end

  [21,101,2345,26871,112200,1723492,
   66287620,112276826,2386520171].each do |number|
    base = number.digits.size
    it "returns false if the number isn't self-descriptive in base #{base}" do
      number.to_s(base).to_i.self_descriptive?(base).should be_false
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
numb-0.186.0 spec/numb/self_descriptive_spec.rb
numb-0.185.0 spec/numb/self_descriptive_spec.rb
numb-0.184.0 spec/numb/self_descriptive_spec.rb
numb-0.181.0 spec/numb/self_descriptive_spec.rb
numb-0.170.0 spec/numb/self_descriptive_spec.rb
numb-0.152.0 spec/numb/self_descriptive_spec.rb
numb-0.138.0 spec/numb/self_descriptive_spec.rb
numb-0.125.0 spec/numb/self_descriptive_spec.rb
numb-0.114.0 spec/numb/self_descriptive_spec.rb
numb-0.111.0 spec/numb/self_descriptive_spec.rb
numb-0.109.0 spec/numb/self_descriptive_spec.rb
numb-0.99.0 spec/numb/self_descriptive_spec.rb
numb-0.96.0 spec/numb/self_descriptive_spec.rb
numb-0.89.0 spec/numb/self_descriptive_spec.rb
numb-0.84.0 spec/self_descriptive_spec.rb
numb-0.77.0 spec/self_descriptive_spec.rb
numb-0.72.1 spec/self_descriptive_spec.rb
numb-0.72.0 spec/self_descriptive_spec.rb
numb-0.68.0 spec/self_descriptive_spec.rb
numb-0.63.0 spec/self_descriptive_spec.rb