Sha256: 94c806f8183d974c3db81ab080d3ba78d880a9481d70e5480260e40d1a049b10

Contents?: true

Size: 667 Bytes

Versions: 30

Compression:

Stored size: 667 Bytes

Contents

describe Integer, "#square?" do
  SQUARES = [0,1,4,9,16,25,36,49,64,81,100,121,144,169,196,
             225,256,289,324,361,400,441,484,529,576,625,676,
             729,784,841,900,961,1024,1089,1156,1225,1296,1369,
             1444,1521,1600,1681,1764,1849]
  
  it "returns true if the number is square" do
    SQUARES.each do |number|
      number.should be_square
    end
  end

  it "returns false if the number isn't square" do
    ((1..1850).to_a - SQUARES).each do |number|
      number.should_not be_square
    end
  end

  it "returns false for negative numbers" do
    [-1, -378, -9].each do |number|
      number.should_not be_square
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
numb-0.138.0 spec/numb/square_spec.rb
numb-0.125.0 spec/numb/square_spec.rb
numb-0.114.0 spec/numb/square_spec.rb
numb-0.111.0 spec/numb/square_spec.rb
numb-0.109.0 spec/numb/square_spec.rb
numb-0.99.0 spec/numb/square_spec.rb
numb-0.96.0 spec/numb/square_spec.rb
numb-0.89.0 spec/numb/square_spec.rb
numb-0.84.0 spec/square_spec.rb
numb-0.77.0 spec/square_spec.rb
numb-0.72.1 spec/square_spec.rb
numb-0.72.0 spec/square_spec.rb
numb-0.68.0 spec/square_spec.rb
numb-0.63.0 spec/square_spec.rb
numb-0.21.0 spec/square_spec.rb
numb-0.20.0 spec/square_spec.rb
numb-0.10.0 spec/square_spec.rb
numb-0.9.0 spec/square_spec.rb
numb-0.8.0 spec/square_spec.rb
numb-0.7.0 spec/square_spec.rb