diff options
author | Nobuyoshi Nakada <[email protected]> | 2022-11-08 09:06:21 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2022-11-10 11:59:45 +0900 |
commit | 6eaed20e145c1ab4c9c4ccf669d0ebea934f4d36 () | |
tree | ec43f8696b661dcd8d19ad60e353999fbac0490b | |
parent | 0ae5de1a5ddcca407dd2ba30ca5d5f3d7c3ea4bc (diff) |
Add version to the interface of Random extensions
-rw-r--r-- | ext/-test-/random/bad_version.c | 132 | ||||
-rw-r--r-- | ext/-test-/random/depend | 160 | ||||
-rw-r--r-- | include/ruby/random.h | 33 | ||||
-rw-r--r-- | random.c | 9 | ||||
-rw-r--r-- | test/-ext-/test_random.rb | 26 |
5 files changed, 356 insertions, 4 deletions
@@ -0,0 +1,132 @@ @@ -1,4 +1,164 @@ # AUTOGENERATED DEPENDENCIES START init.o: $(RUBY_EXTCONF_H) init.o: $(arch_hdrdir)/ruby/config.h init.o: $(hdrdir)/ruby.h @@ -16,6 +16,26 @@ #include "ruby/ruby.h" RBIMPL_SYMBOL_EXPORT_BEGIN() /** @@ -84,6 +104,18 @@ typedef struct { /** Number of bits of seed numbers. */ size_t default_seed_bits; /** Initialiser function. */ rb_random_init_func *init; @@ -161,6 +193,7 @@ typedef struct { * ``` */ #define RB_RANDOM_INTERFACE_DEFINE(prefix) \ prefix##_init, \ prefix##_get_int32, \ prefix##_get_bytes @@ -400,6 +400,15 @@ random_init(int argc, VALUE *argv, VALUE obj) rb_raise(rb_eTypeError, "undefined random interface: %s", RTYPEDDATA_TYPE(obj)->wrap_struct_name); } argc = rb_check_arity(argc, 0, 1); rb_check_frozen(obj); if (argc == 0) { @@ -1,11 +1,13 @@ 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) @@ -24,4 +26,20 @@ module TestRandomExt assert_equal(1.00, Bug::Random::Loop.new(4<<14).rand) end end end |