summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-11-08 09:06:21 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-11-10 11:59:45 +0900
commit6eaed20e145c1ab4c9c4ccf669d0ebea934f4d36 (patch)
treeec43f8696b661dcd8d19ad60e353999fbac0490b /test
parent0ae5de1a5ddcca407dd2ba30ca5d5f3d7c3ea4bc (diff)
Add version to the interface of Random extensions
Diffstat (limited to 'test')
-rw-r--r--test/-ext-/test_random.rb26
1 files changed, 22 insertions, 4 deletions
diff --git a/test/-ext-/test_random.rb b/test/-ext-/test_random.rb
index 838e5d2f14..e5cebcc871 100644
--- a/test/-ext-/test_random.rb
+++ b/test/-ext-/test_random.rb
@@ -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