Skip to content

Commit 6d3a365

Browse files
committed
[GR-15736] Fix BigDecimal#dup to return the receiver rather than a new object.
PullRequest: truffleruby/833
2 parents 0eaec38 + 2564660 commit 6d3a365

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 1.0 RC 18
2+
3+
Bug fixes:
4+
5+
* Fixed `BigDecimal#dup` so it now just returns the receiver, per Ruby 2.5+ semantics (#1680).
6+
17
# 1.0 RC 17
28

39
Bug fixes:

lib/truffle/bigdecimal.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ def self.limit(limit = nil)
7979
end
8080
end
8181

82+
def dup
83+
self
84+
end
85+
8286
# TODO (pitr 20-jun-2015): remove when lazy setup is added
8387
def self.name
8488
'BigDecimal'
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
require_relative '../../spec_helper'
2+
require 'bigdecimal'
3+
4+
describe "BigDecimal#dup" do
5+
before :each do
6+
@obj = BigDecimal("1.2345")
7+
end
8+
9+
ruby_version_is "" ... "2.5" do
10+
it "copies the BigDecimal's value to a newly allocated object" do
11+
copy = @obj.dup
12+
13+
copy.should_not equal(@obj)
14+
copy.should == @obj
15+
end
16+
end
17+
18+
ruby_version_is "2.5" do
19+
it "returns self" do
20+
@obj.dup.should equal(@obj)
21+
end
22+
end
23+
end

0 commit comments

Comments
 (0)