We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b3dffba commit b0b32daCopy full SHA for b0b32da
spec/ruby/optional/capi/bignum_spec.rb
@@ -97,6 +97,16 @@ def ensure_bignum(n)
97
end
98
99
100
+ describe "RBIGNUM_SIGN" do
101
+ it "returns 1 for a positive Bignum" do
102
+ @s.RBIGNUM_SIGN(bignum_value(1)).should == 1
103
+ end
104
+
105
+ it "returns 0 for a negative Bignum" do
106
+ @s.RBIGNUM_SIGN(-bignum_value(1)).should == 0
107
108
109
110
describe "rb_big_cmp" do
111
it "compares a Bignum with a Bignum" do
112
@s.rb_big_cmp(bignum_value, bignum_value(1)).should == -1
spec/ruby/optional/capi/ext/bignum_spec.c
@@ -31,6 +31,10 @@ static VALUE bignum_spec_rb_big2ulong(VALUE self, VALUE num) {
31
return ULONG2NUM(rb_big2ulong(num));
32
}
33
34
+static VALUE bignum_spec_RBIGNUM_SIGN(VALUE self, VALUE val) {
35
+ return INT2FIX(RBIGNUM_SIGN(val));
36
+}
37
38
static VALUE bignum_spec_rb_big_cmp(VALUE self, VALUE x, VALUE y) {
39
return rb_big_cmp(x, y);
40
@@ -90,6 +94,7 @@ void Init_bignum_spec(void) {
90
94
rb_define_method(cls, "rb_big2long", bignum_spec_rb_big2long, 1);
91
95
rb_define_method(cls, "rb_big2str", bignum_spec_rb_big2str, 2);
92
96
rb_define_method(cls, "rb_big2ulong", bignum_spec_rb_big2ulong, 1);
+ rb_define_method(cls, "RBIGNUM_SIGN", bignum_spec_RBIGNUM_SIGN, 1);
93
rb_define_method(cls, "rb_big_cmp", bignum_spec_rb_big_cmp, 2);
rb_define_method(cls, "rb_big_pack", bignum_spec_rb_big_pack, 1);
rb_define_method(cls, "rb_big_pack_array", bignum_spec_rb_big_pack_array, 2);
0 commit comments