Sha256: 1fdf31860aa298e10b40858ac466860c14965e8501df2954629433dd930b6ad1

Contents?: true

Size: 540 Bytes

Versions: 48

Compression:

Stored size: 540 Bytes

Contents

describe "Kernel.rand" do
  it "returns a float if no argument is passed" do
    rand.should be_kind_of(Float)
  end

  it "returns an integer for an integer argument" do
    rand(77).should be_kind_of(Integer)
  end

  it "return member from range" do
    r = (1..10)
    r.to_a.include?(rand(r)).should == true
  end

  it "should convert negative number and convert to integer" do
    rand(-0.1).should == 0
  end

  it "returns a numeric in opal" do
    rand.should be_kind_of(Numeric)
    rand(77).should be_kind_of(Numeric)
  end
end

Version data entries

48 entries across 48 versions & 3 rubygems

Version Path
opal-0.10.6 spec/opal/core/kernel/rand_spec.rb
opal-0.10.6.beta spec/opal/core/kernel/rand_spec.rb
opal-0.10.5 spec/opal/core/kernel/rand_spec.rb
opal-0.10.4 spec/opal/core/kernel/rand_spec.rb
opal-0.10.3 spec/opal/core/kernel/rand_spec.rb
opal-0.10.2 spec/opal/core/kernel/rand_spec.rb
opal-0.10.1 spec/opal/core/kernel/rand_spec.rb
opal-0.10.0 spec/opal/core/kernel/rand_spec.rb
opal-0.10.0.rc2 spec/opal/core/kernel/rand_spec.rb
opal-0.9.4 spec/opal/core/kernel/rand_spec.rb
opal-0.9.3 spec/opal/core/kernel/rand_spec.rb
opal-0.10.0.rc1 spec/opal/core/kernel/rand_spec.rb
opal-0.10.0.beta5 spec/opal/core/kernel/rand_spec.rb
opal-0.10.0.beta4 spec/opal/core/kernel/rand_spec.rb
opal-0.10.0.beta3 spec/opal/core/kernel/rand_spec.rb
opal-0.10.0.beta2 spec/opal/core/kernel/rand_spec.rb
opal-0.10.0.beta1 spec/opal/core/kernel/rand_spec.rb
opal-0.9.2 spec/opal/core/kernel/rand_spec.rb
opal-0.9.0 spec/opal/core/kernel/rand_spec.rb
opal-0.9.0.rc1 spec/opal/core/kernel/rand_spec.rb