Add version to the interface of Random extensions

This commit is contained in:
Nobuyoshi Nakada 2022-11-08 09:06:21 +09:00
parent 0ae5de1a5d
commit 6eaed20e14
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
5 changed files with 356 additions and 4 deletions

View file

@ -1,11 +1,13 @@
require 'test/unit'
module TestRandomExt
def setup
super
assert_nothing_raised(LoadError) {require '-test-/random'}
end
class TestLoop < Test::Unit::TestCase
def setup
super
assert_nothing_raised(LoadError) {require '-test-/random'}
end
include TestRandomExt
def test_bytes
rnd = Bug::Random::Loop.new(1)
@ -24,4 +26,20 @@ module TestRandomExt
assert_equal(1.00, Bug::Random::Loop.new(4<<14).rand)
end
end
class TestVersionZero < Test::Unit::TestCase
include TestRandomExt
def test_bad_version
assert_raise(TypeError) {Bug::Random::VersionZero.new}
end
end
class TestVersionMax < Test::Unit::TestCase
include TestRandomExt
def test_bad_version
assert_raise(TypeError) {Bug::Random::VersionMax.new}
end
end
end