Sha256: 52731feb5e09a0109cab8fed9323e7b8ca9e6852edfdfeb756e4477a3345098e

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

#==============================================================================#
# $Id: test_rand.rb 37 2007-08-27 13:02:39Z yuyakato $
#==============================================================================#

require File.dirname(__FILE__) + "/test_helper.rb"
require File.dirname(__FILE__) + "/../lib/kagemusha/rand"

#==============================================================================#

class TestKagemushaRand < Test::Unit::TestCase
  def setup
  end

  def test_always
    musha = Kagemusha::Rand.always(1)
    assert_equal(Kernel, musha.instance_eval { @klass })
    musha.swap {
      assert_equal(1, rand)
      assert_equal(1, rand(2))
      assert_equal(1, rand(3))
      assert_equal(1, rand(4))
      assert_equal(1, rand(5))
    }
  end

  def test_always_with_block
    ret = Kagemusha::Rand.always(1) {
      assert_equal(1, rand)
      assert_equal(1, rand(2))
      assert_equal(1, rand(3))
      assert_equal(1, rand(4))
      assert_equal(1, rand(5))
      1
    }

    assert_equal(1, ret)
  end
end

#==============================================================================#
#==============================================================================#

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kagemusha-0.0.2 test/test_rand.rb
kagemusha-0.0.3 test/test_rand.rb
kagemusha-0.0.4 test/test_rand.rb