summaryrefslogtreecommitdiff
path: root/test/-ext-
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2016-05-07 11:51:14 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-09-07 20:08:01 +0900
commitaf5e87ab218c5f4e34c6cdb54ae119a7f0f9033f (patch)
treee050cf7f7af91f1b990287f6e17d26bc27b6171d /test/-ext-
parentf4d5273989ae8d6569a62b126b2774706b86fbf5 (diff)
separate rb_random_t
* random.c: separate abstract rb_random_t and rb_random_mt_t for Mersenne Twister implementation. * include/ruby/random.h: the interface for extensions of Random class. * DLL imported symbol reference is not constant on Windows. * check if properly initialized.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3024
Diffstat (limited to 'test/-ext-')
-rw-r--r--test/-ext-/test_random.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/-ext-/test_random.rb b/test/-ext-/test_random.rb
new file mode 100644
index 0000000000..da716c71c0
--- /dev/null
+++ b/test/-ext-/test_random.rb
@@ -0,0 +1,20 @@
+require 'test/unit'
+
+module TestRandomExt
+ class TestLoop < Test::Unit::TestCase
+ def setup
+ super
+ assert_nothing_raised(LoadError) {require '-test-/random'}
+ end
+
+ def test_bytes
+ rnd = Bug::Random::Loop.new(1)
+ assert_equal("\1", rnd.bytes(1))
+ end
+
+ def test_rand
+ rnd = Bug::Random::Loop.new(1)
+ assert_equal(1, rnd.rand(10))
+ end
+ end
+end