Skip to content

Instantly share code, notes, and snippets.

View kronos's full-sized avatar
👨‍💻

Ivan Samsonov kronos

👨‍💻
View GitHub Profile
diff --git a/spec/ruby/core/bignum/bit_xor_spec.rb b/spec/ruby/core/bignum/bit_xor_spec.rb
index 38a5850..26a38ea 100644
--- a/spec/ruby/core/bignum/bit_xor_spec.rb
+++ b/spec/ruby/core/bignum/bit_xor_spec.rb
@@ -11,6 +11,18 @@ describe "Bignum#^" do
(@bignum ^ 14).should == 9223372036854775836
end
+ it "returns self bitwise EXCLUSIVE OR negative other when one operand is negative" do
+ (@bignum ^ -0x40000000000000000).should == -64563604257983430638
diff --git a/vm/builtin/bignum.cpp b/vm/builtin/bignum.cpp
index 163f207..e0f5e24 100644
--- a/vm/builtin/bignum.cpp
+++ b/vm/builtin/bignum.cpp
@@ -96,22 +96,14 @@ namespace rubinius {
return res;
}
- static void twos_complement(mp_int *a)
+ static void twos_complement MPA(mp_int *a)
diff --git a/spec/ruby/language/defined_spec.rb b/spec/ruby/language/defined_spec.rb
index 516f86b..e665fa0 100644
--- a/spec/ruby/language/defined_spec.rb
+++ b/spec/ruby/language/defined_spec.rb
@@ -43,6 +43,10 @@ describe "The defined? keyword when called with a method name" do
defined?(Object.print).should be_nil
end
+ it "returns nil if the method is protected" do
+ defined?(DefinedSpecs::Basic.new.protected_method).should be_nil
diff --git a/kernel/common/global.rb b/kernel/common/global.rb
index fb80419..4cbbd1e 100644
--- a/kernel/common/global.rb
+++ b/kernel/common/global.rb
@@ -84,7 +84,7 @@ module Rubinius
end
def illegal_set(*args)
- raise RuntimeError, "unable to set global"
+ raise NameError, "#{args[0]} is a read-only variable"
diff --git a/spec/ruby/core/bignum/bit_xor_spec.rb b/spec/ruby/core/bignum/bit_xor_spec.rb
index 38a5850..26a38ea 100644
--- a/spec/ruby/core/bignum/bit_xor_spec.rb
+++ b/spec/ruby/core/bignum/bit_xor_spec.rb
@@ -11,6 +11,18 @@ describe "Bignum#^" do
(@bignum ^ 14).should == 9223372036854775836
end
+ it "returns self bitwise EXCLUSIVE OR negative other when one operand is negative" do
+ (@bignum ^ -0x40000000000000000).should == -64563604257983430638
diff --git a/spec/ruby/core/bignum/bit_and_spec.rb b/spec/ruby/core/bignum/bit_and_spec.rb
index d77fa4b..d141f7b 100644
--- a/spec/ruby/core/bignum/bit_and_spec.rb
+++ b/spec/ruby/core/bignum/bit_and_spec.rb
@@ -12,9 +12,21 @@ describe "Bignum#&" do
(@bignum & bignum_value(9921)).should == 9223372036854775809
((2*bignum_value) & 1).should == 0
+ ((2*bignum_value) & (2*bignum_value)).should == 18446744073709551616
+ end
diff --git a/vm/builtin/bignum.cpp b/vm/builtin/bignum.cpp
index e0f5e24..cc2abeb 100644
--- a/vm/builtin/bignum.cpp
+++ b/vm/builtin/bignum.cpp
@@ -646,7 +646,7 @@ namespace rubinius {
Integer* Bignum::left_shift(STATE, Fixnum* bits) {
NMP;
- int shift = bits->to_native();
+ native_int shift = bits->to_native();
static VALUE
fix_lshift(val, width)
long val;
unsigned long width;
{
if (width > (sizeof(VALUE)*CHAR_BIT-1)
|| ((unsigned long)val)>>(sizeof(VALUE)*CHAR_BIT-1-width) > 0) {
return rb_big_lshift(rb_int2big(val), ULONG2NUM(width));
}
val = val << width;
diff --git a/spec/ruby/core/fixnum/left_shift_spec.rb b/spec/ruby/core/fixnum/left_shift_spec.rb
index 38b8bcf..8aa5d25 100644
--- a/spec/ruby/core/fixnum/left_shift_spec.rb
+++ b/spec/ruby/core/fixnum/left_shift_spec.rb
@@ -24,6 +24,7 @@ describe "Fixnum#<<" do
it "coerces result on overflow and return self shifted left other bits" do
(9 << 4.2).should == 144
(6 << 0xff).should == 347376267711948586270712955026063723559809953996921692118372752023739388919808
+ (-4518325415524767873 << 32).should == -19406059892364488692526481408
end
diff --git a/vm/builtin/fixnum.cpp b/vm/builtin/fixnum.cpp
index 679c5f1..5d51798 100644
--- a/vm/builtin/fixnum.cpp
+++ b/vm/builtin/fixnum.cpp
@@ -126,7 +126,7 @@ namespace rubinius {
native_int denominator = other->to_native();
native_int quotient = div(state, other)->to_native();
native_int modulo = numerator - denominator * quotient;
-
+