Skip to content

Commit 7e13fbc

Browse files
tompngsoutaro
andauthored
Update bundled bigdecimal and rbs (ruby#15611)
* Bundle rbs-3.10.0.pre.1 * Update rbs gem entry with commit hash Updated rbs entry to include commit hash. * Fix rbs entry in bundled_gems * Update rbs gem to version 3.10.0.pre.2 Updated rbs gem version from 3.10.0.pre.1 to 3.10.0.pre.2. * Update bundled bigdecimal to v4.0.1 --------- Co-authored-by: Soutaro Matsumoto <[email protected]>
1 parent 56b67f1 commit 7e13fbc

File tree

6 files changed

+51
-164
lines changed

6 files changed

+51
-164
lines changed

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ The following bundled gems are updated.
337337
* typeprof 0.31.0
338338
* debug 1.11.0
339339
* base64 0.3.0
340-
* bigdecimal 3.3.1
340+
* bigdecimal 4.0.1
341341
* drb 2.2.3
342342
* syslog 0.3.0
343343
* csv 3.3.5

gems/bundled_gems

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ net-pop 0.1.2 https://github.com/ruby/net-pop
1818
net-smtp 0.5.1 https://github.com/ruby/net-smtp
1919
matrix 0.4.3 https://github.com/ruby/matrix
2020
prime 0.1.4 https://github.com/ruby/prime
21-
rbs 3.9.5 https://github.com/ruby/rbs 22451ecbe262326176eb3915b64366712930685c # waiting for https://github.com/ruby/rbs/pull/2706
21+
rbs 3.10.0.pre.2 https://github.com/ruby/rbs
2222
typeprof 0.31.0 https://github.com/ruby/typeprof
2323
debug 1.11.0 https://github.com/ruby/debug
2424
racc 1.8.1 https://github.com/ruby/racc
2525
mutex_m 0.3.0 https://github.com/ruby/mutex_m
2626
getoptlong 0.2.1 https://github.com/ruby/getoptlong
2727
base64 0.3.0 https://github.com/ruby/base64
28-
bigdecimal 3.3.1 https://github.com/ruby/bigdecimal
28+
bigdecimal 4.0.1 https://github.com/ruby/bigdecimal
2929
observer 0.1.2 https://github.com/ruby/observer
3030
abbrev 0.1.2 https://github.com/ruby/abbrev
3131
resolv-replace 0.1.1 https://github.com/ruby/resolv-replace

spec/ruby/library/bigdecimal/BigDecimal_spec.rb

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,12 @@
3131
end
3232

3333
it "accepts significant digits >= given precision" do
34-
suppress_warning do
35-
BigDecimal("3.1415923", 10).precs[1].should >= 10
36-
end
34+
BigDecimal("3.1415923", 10).should == BigDecimal("3.1415923")
3735
end
3836

3937
it "determines precision from initial value" do
4038
pi_string = "3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593014782083152134043"
41-
suppress_warning {
42-
BigDecimal(pi_string).precs[1]
43-
}.should >= pi_string.size-1
39+
BigDecimal(pi_string).precision.should == pi_string.size-1
4440
end
4541

4642
it "ignores leading and trailing whitespace" do
@@ -208,14 +204,6 @@ def to_s; "cheese"; end
208204
Float(@b).to_s.should == "166.66666666666666"
209205
end
210206

211-
it "has the expected precision on the LHS" do
212-
suppress_warning { @a.precs[0] }.should == 18
213-
end
214-
215-
it "has the expected maximum precision on the LHS" do
216-
suppress_warning { @a.precs[1] }.should == 27
217-
end
218-
219207
it "produces the expected result when done via Float" do
220208
(Float(@a) - Float(@b)).to_s.should == "-6.666596163995564e-10"
221209
end
@@ -226,34 +214,10 @@ def to_s; "cheese"; end
226214

227215
# Check underlying methods work as we understand
228216

229-
it "BigDecimal precision is the number of digits rounded up to a multiple of nine" do
230-
1.upto(100) do |n|
231-
b = BigDecimal('4' * n)
232-
precs, _ = suppress_warning { b.precs }
233-
(precs >= 9).should be_true
234-
(precs >= n).should be_true
235-
(precs % 9).should == 0
236-
end
237-
suppress_warning { BigDecimal('NaN').precs[0] }.should == 9
238-
end
239-
240-
it "BigDecimal maximum precision is nine more than precision except for abnormals" do
241-
1.upto(100) do |n|
242-
b = BigDecimal('4' * n)
243-
precs, max = suppress_warning { b.precs }
244-
max.should == precs + 9
245-
end
246-
suppress_warning { BigDecimal('NaN').precs[1] }.should == 9
247-
end
248-
249217
it "BigDecimal(Rational, 18) produces the result we expect" do
250218
BigDecimal(@b, 18).to_s.should == "0.166666666666666667e3"
251219
end
252220

253-
it "BigDecimal(Rational, BigDecimal.precs[0]) produces the result we expect" do
254-
BigDecimal(@b, suppress_warning { @a.precs[0] }).to_s.should == "0.166666666666666667e3"
255-
end
256-
257221
# Check the top-level expression works as we expect
258222

259223
it "produces a BigDecimal" do

spec/ruby/library/bigdecimal/divmod_spec.rb

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ class BigDecimal
3333
end
3434
end
3535

36-
it_behaves_like :bigdecimal_modulo, :mod_part_of_divmod
36+
version_is BigDecimal::VERSION, ""..."4.0.0" do
37+
it_behaves_like :bigdecimal_modulo, :mod_part_of_divmod
38+
end
3739

3840
it "raises ZeroDivisionError if other is zero" do
3941
bd5667 = BigDecimal("5667.19")
40-
42+
zero = BigDecimal("0")
4143
-> { bd5667.mod_part_of_divmod(0) }.should raise_error(ZeroDivisionError)
4244
-> { bd5667.mod_part_of_divmod(BigDecimal("0")) }.should raise_error(ZeroDivisionError)
43-
-> { @zero.mod_part_of_divmod(@zero) }.should raise_error(ZeroDivisionError)
45+
-> { zero.mod_part_of_divmod(zero) }.should raise_error(ZeroDivisionError)
4446
end
4547
end
4648

@@ -73,14 +75,25 @@ class BigDecimal
7375
@zeroes = [@zero, @zero_pos, @zero_neg]
7476
end
7577

76-
it "divides value, returns an array" do
77-
res = @a.divmod(5)
78-
res.kind_of?(Array).should == true
78+
version_is BigDecimal::VERSION, ""..."4.0.0" do
79+
it "divides value, returns [BigDecimal, BigDecimal]" do
80+
res = @a.divmod(5)
81+
res.kind_of?(Array).should == true
82+
DivmodSpecs.check_both_bigdecimal(res)
83+
end
84+
end
85+
86+
version_is BigDecimal::VERSION, "4.0.0" do
87+
it "divides value, returns [Integer, BigDecimal]" do
88+
res = @a.divmod(5)
89+
res.kind_of?(Array).should == true
90+
res[0].kind_of?(Integer).should == true
91+
res[1].kind_of?(BigDecimal).should == true
92+
end
7993
end
8094

8195
it "array contains quotient and modulus as BigDecimal" do
8296
res = @a.divmod(5)
83-
DivmodSpecs.check_both_bigdecimal(res)
8497
res[0].should == BigDecimal('0.8E1')
8598
res[1].should == BigDecimal('2.00000000000000000001')
8699

@@ -123,17 +136,27 @@ class BigDecimal
123136
values_and_zeroes.each do |val1|
124137
values.each do |val2|
125138
res = val1.divmod(val2)
126-
DivmodSpecs.check_both_bigdecimal(res)
127139
res[0].should == ((val1/val2).floor)
128140
res[1].should == (val1 - res[0] * val2)
129141
end
130142
end
131143
end
132144

133-
it "returns an array of two NaNs if NaN is involved" do
134-
(@special_vals + @regular_vals + @zeroes).each do |val|
135-
DivmodSpecs.check_both_nan(val.divmod(@nan))
136-
DivmodSpecs.check_both_nan(@nan.divmod(val))
145+
version_is BigDecimal::VERSION, "4.0.0" do
146+
it "raise FloatDomainError error if NaN is involved" do
147+
(@special_vals + @regular_vals + @zeroes).each do |val|
148+
-> { val.divmod(@nan) }.should raise_error(FloatDomainError)
149+
-> { @nan.divmod(val) }.should raise_error(FloatDomainError)
150+
end
151+
end
152+
end
153+
154+
version_is BigDecimal::VERSION, ""..."4.0.0" do
155+
it "returns an array of two NaNs if NaN is involved" do
156+
(@special_vals + @regular_vals + @zeroes).each do |val|
157+
DivmodSpecs.check_both_nan(val.divmod(@nan))
158+
DivmodSpecs.check_both_nan(@nan.divmod(val))
159+
end
137160
end
138161
end
139162

@@ -145,12 +168,14 @@ class BigDecimal
145168
end
146169
end
147170

148-
it "returns an array of Infinity and NaN if the dividend is Infinity" do
149-
@regular_vals.each do |val|
150-
array = @infinity.divmod(val)
151-
array.length.should == 2
152-
array[0].infinite?.should == (val > 0 ? 1 : -1)
153-
array[1].should.nan?
171+
version_is BigDecimal::VERSION, ""..."4.0.0" do
172+
it "returns an array of Infinity and NaN if the dividend is Infinity" do
173+
@regular_vals.each do |val|
174+
array = @infinity.divmod(val)
175+
array.length.should == 2
176+
array[0].infinite?.should == (val > 0 ? 1 : -1)
177+
array[1].should.nan?
178+
end
154179
end
155180
end
156181

spec/ruby/library/bigdecimal/precs_spec.rb

Lines changed: 0 additions & 55 deletions
This file was deleted.

tool/rbs_skip_tests

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -46,53 +46,6 @@ test_new(RegexpSingletonTest)
4646

4747
## Failed tests caused by unreleased version of Ruby
4848

49-
# https://github.com/ruby/openssl/pull/774
50-
test_params(OpenSSLDHTest)
51-
52-
# RBS isn't compatible with RDoc 6.13
53-
RDocPluginParserTest
54-
55-
# https://github.com/ruby/json/pull/773
56-
test_load(JSONInstanceTest)
57-
test_load(JSONSingletonTest)
58-
59-
# https://github.com/ruby/json/pull/775
60-
test_fast_unparse(JSONInstanceTest)
61-
test_pretty_unparse(JSONInstanceTest)
62-
test_restore(JSONInstanceTest)
63-
test_unparse(JSONInstanceTest)
64-
test_fast_unparse(JSONSingletonTest)
65-
test_pretty_unparse(JSONSingletonTest)
66-
test_restore(JSONSingletonTest)
67-
test_unparse(JSONSingletonTest)
68-
69-
# https://github.com/ruby/json/pull/779
70-
test_iconv(JSONSingletonTest)
71-
72-
# https://github.com/ruby/json/pull/774
73-
test_recurse_proc(JSONInstanceTest)
74-
test_recurse_proc(JSONSingletonTest)
75-
76-
test_deep_const_get(JSONSingletonTest)
77-
78-
CGITest CGI is retired
79-
CGISingletonTest CGI is retired
80-
81-
RactorSingletonTest Ractor API was changed https://bugs.ruby-lang.org/issues/21262
82-
RactorInstanceTest Ractor API was changed https://bugs.ruby-lang.org/issues/21262
83-
84-
# https://github.com/ruby/fileutils/pull/139
85-
# https://github.com/ruby/actions/actions/runs/16425309325/job/46414287784
86-
test_ln_sr(FileUtilsSingletonTest)
87-
88-
# https://github.com/ruby/ruby/pull/14303
89-
# NoMethodError: undefined method 'respond_to?' for an instance of RBS::UnitTest::Convertibles::ToStr
90-
test_join(PathnameInstanceTest)
91-
test_plus(PathnameInstanceTest)
92-
test_relative_path_from(PathnameInstanceTest)
93-
test_slash(PathnameInstanceTest)
94-
test_Pathname(PathnameKernelTest)
95-
test_initialize(PathnameSingletonTest)
96-
97-
# [Feature #20925] `size` of Enumerator created by `produce` returns `nil` instead of `Float::INFINITY`, unless `size:` is specified.
98-
test_produce(EnumeratorSingletonTest)
49+
# BigDecimal v4.0.0 changed behavior
50+
test_divmod(BigDecimalTest)
51+
test_precs(BigDecimalTest)

0 commit comments

Comments
 (0)