1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

forgot to commit.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2016-05-17 08:25:58 +00:00
parent f9727c12cc
commit 1afbc71ac2
3 changed files with 48 additions and 0 deletions

View file

@ -0,0 +1,8 @@
# frozen_string_literal: false
$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
inits = $srcs.map {|s| File.basename(s, ".*")}
inits.delete("init")
inits.map! {|s|"X(#{s})"}
$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
create_makefile("-test-/testutil")

View file

@ -0,0 +1,11 @@
#include "ruby.h"
#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
void
Init_testutil(void)
{
VALUE mBug = rb_define_module("Bug");
VALUE klass = rb_define_class_under(mBug, "TestUtil", rb_cObject);
TEST_INIT_FUNCS(init);
}

View file

@ -0,0 +1,29 @@
#include "internal.h"
static VALUE
int_bignum_p(VALUE self)
{
return RB_TYPE_P(self, T_BIGNUM) ? Qtrue : Qfalse;
}
static VALUE
int_fixnum_p(VALUE self)
{
return FIXNUM_P(self) ? Qtrue : Qfalse;
}
static VALUE
rb_int_to_bignum(VALUE x)
{
if (FIXNUM_P(x))
x = rb_int2big(FIX2LONG(x));
return x;
}
void
Init_integer(VALUE klass)
{
rb_define_method(rb_cInteger, "bignum?", int_bignum_p, 0);
rb_define_method(rb_cInteger, "fixnum?", int_fixnum_p, 0);
rb_define_method(rb_cInteger, "to_bignum", rb_int_to_bignum, 0);
}