summaryrefslogtreecommitdiff
path: root/ext/-test-/num2int
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-31 16:14:15 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-31 16:14:15 +0000
commita7526797a65a2f51bc93561c9545fddcd3c3e012 (patch)
treec25677641e922369956efed52af691bb053904a1 /ext/-test-/num2int
parentc68234f7d1fa9f2e9a1874b547f1f3e48eff5ae1 (diff)
* include/ruby/ruby.h (FIX2ULONG): Make it consistent with NUM2ULONG.
* ext/-test-/num2int/num2int.c: Add utility methods for FIX2XXX tests. * test/-ext-/num2int/test_num2int.rb: Add tests for FIX2XXX. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/-test-/num2int')
-rw-r--r--ext/-test-/num2int/num2int.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/ext/-test-/num2int/num2int.c b/ext/-test-/num2int/num2int.c
index fb1ea96..f433858 100644
--- a/ext/-test-/num2int/num2int.c
+++ b/ext/-test-/num2int/num2int.c
@@ -98,6 +98,66 @@ print_num2ull(VALUE obj, VALUE num)
}
#endif
+static VALUE
+print_fix2short(VALUE obj, VALUE num)
+{
+ char buf[128];
+ VALUE str;
+
+ sprintf(buf, "%d", FIX2SHORT(num));
+ str = rb_str_new_cstr(buf);
+ rb_io_write(rb_stdout, str);
+ return Qnil;
+}
+
+static VALUE
+print_fix2int(VALUE obj, VALUE num)
+{
+ char buf[128];
+ VALUE str;
+
+ sprintf(buf, "%d", FIX2INT(num));
+ str = rb_str_new_cstr(buf);
+ rb_io_write(rb_stdout, str);
+ return Qnil;
+}
+
+static VALUE
+print_fix2uint(VALUE obj, VALUE num)
+{
+ char buf[128];
+ VALUE str;
+
+ sprintf(buf, "%u", FIX2UINT(num));
+ str = rb_str_new_cstr(buf);
+ rb_io_write(rb_stdout, str);
+ return Qnil;
+}
+
+static VALUE
+print_fix2long(VALUE obj, VALUE num)
+{
+ char buf[128];
+ VALUE str;
+
+ sprintf(buf, "%ld", FIX2LONG(num));
+ str = rb_str_new_cstr(buf);
+ rb_io_write(rb_stdout, str);
+ return Qnil;
+}
+
+static VALUE
+print_fix2ulong(VALUE obj, VALUE num)
+{
+ char buf[128];
+ VALUE str;
+
+ sprintf(buf, "%lu", FIX2ULONG(num));
+ str = rb_str_new_cstr(buf);
+ rb_io_write(rb_stdout, str);
+ return Qnil;
+}
+
void
Init_num2int(void)
{
@@ -116,5 +176,13 @@ Init_num2int(void)
rb_define_singleton_method(cNum2int, "print_num2ll", print_num2ll, 1);
rb_define_singleton_method(cNum2int, "print_num2ull", print_num2ull, 1);
#endif
+
+ rb_define_singleton_method(cNum2int, "print_fix2short", print_fix2short, 1);
+
+ rb_define_singleton_method(cNum2int, "print_fix2int", print_fix2int, 1);
+ rb_define_singleton_method(cNum2int, "print_fix2uint", print_fix2uint, 1);
+
+ rb_define_singleton_method(cNum2int, "print_fix2long", print_fix2long, 1);
+ rb_define_singleton_method(cNum2int, "print_fix2ulong", print_fix2ulong, 1);
}