Sha256: 9378efcc57db4c1a4743cf609e892cb6a26fe692f160950c74f208c40430b802
Contents?: true
Size: 796 Bytes
Versions: 2
Compression:
Stored size: 796 Bytes
Contents
describe Integer, "#cube?" do # A000578 CUBES = [0,1,8,27,64,125,216,343,512,729,1000,1331,1728, 2197,2744,3375,4096,4913,5832,6859,8000,9261, 10648,12167,13824,15625,17576,19683,21952,24389, 27000,29791,32768,35937,39304,42875,46656,50653, 54872,59319,64000] it "returns true for perfect cubes" do CUBES.each{|n| n.should be_cube} end it "returns true for negative perfect cubes" do CUBES.shuffle.first(10).each{|n| (-n).should be_cube} end it "returns false for non-perfect cubes" do ((0..CUBES.last).to_a - CUBES).shuffle.first(10).each{|n| n.should_not be_cube} end it "returns false for negative non-perfect cubes" do ((0..CUBES.last).to_a - CUBES).shuffle.first(10).each{|n| (-n).should_not be_cube} end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
numb-0.21.0 | spec/cube_spec.rb |
numb-0.20.0 | spec/cube_spec.rb |