diff options
Diffstat (limited to 'spec/ruby/core/integer/plus_spec.rb')
-rw-r--r-- | spec/ruby/core/integer/plus_spec.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/ruby/core/integer/plus_spec.rb b/spec/ruby/core/integer/plus_spec.rb index be626c3305..511a436872 100644 --- a/spec/ruby/core/integer/plus_spec.rb +++ b/spec/ruby/core/integer/plus_spec.rb @@ -40,4 +40,19 @@ describe "Integer#+" do -> { @bignum + :symbol}.should raise_error(TypeError) end end + + it "can be redefined" do + code = <<~RUBY + class Integer + alias_method :old_plus, :+ + def +(other) + self - other + end + end + result = 1 + 2 + Integer.alias_method :+, :old_plus + print result + RUBY + ruby_exe(code).should == "-1" + end end |