Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,9 @@ Note: We're only listing outstanding class updates.
* When a user-specified timeout occurred in `TCPSocket.new`, either `Errno::ETIMEDOUT`
or `IO::TimeoutError` could previously be raised depending on the situation.
This behavior has been unified so that `IO::TimeoutError` is now consistently raised.
(Please note that, in `Socket.tcp`, there are still cases where `Errno::ETIMEDOUT` may
be raised in similar situations.)
(Please note that, in `Socket.tcp`, there are still cases where `Errno::ETIMEDOUT`
may be raised in similar situations, and that in both cases `Errno::ETIMEDOUT` may be
raised when the timeout occurs at the OS level.)

* String

Expand Down Expand Up @@ -270,7 +271,7 @@ The following bundled gems are promoted from default gems.
* logger 1.7.0
* rdoc 6.17.0
* win32ole 1.9.2
* irb 1.15.3
* irb 1.16.0
* reline 0.6.3
* readline 0.0.4
* fiddle 1.1.8
Expand Down Expand Up @@ -328,15 +329,15 @@ The following bundled gems are updated.
* test-unit 3.7.3
* rexml 3.4.4
* net-ftp 0.3.9
* net-imap 0.5.12
* net-imap 0.6.1
* net-smtp 0.5.1
* matrix 0.4.3
* prime 0.1.4
* rbs 3.9.5
* rbs 3.10.0.pre.2
* typeprof 0.31.0
* debug 1.11.0
* base64 0.3.0
* bigdecimal 3.3.1
* bigdecimal 4.0.1
* drb 2.2.3
* syslog 0.3.0
* csv 3.3.5
Expand Down
56 changes: 49 additions & 7 deletions ext/objspace/objspace_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "ruby/util.h"
#include "ruby/io.h"
#include "vm_callinfo.h"
#include "vm_core.h"
#include "vm_sync.h"

RUBY_EXTERN const char ruby_hexdigits[];

Expand Down Expand Up @@ -771,22 +771,33 @@ dump_result(struct dump_config *dc)
return dc->given_output;
}

/* :nodoc: */
static VALUE
objspace_dump(VALUE os, VALUE obj, VALUE output)
dump_locked(void *args_p)
{
struct dump_config dc = {0,};
VALUE obj = ((VALUE*)args_p)[0];
VALUE output = ((VALUE*)args_p)[1];

if (!RB_SPECIAL_CONST_P(obj)) {
dc.cur_page_slot_size = rb_gc_obj_slot_size(obj);
}

dump_output(&dc, output, Qnil, Qnil, Qnil);

dump_object(obj, &dc);

return dump_result(&dc);
}

/* :nodoc: */
static VALUE
objspace_dump(VALUE os, VALUE obj, VALUE output)
{
VALUE args[2];
args[0] = obj;
args[1] = output;
return rb_vm_lock_with_barrier(dump_locked, (void*)args);
}

static void
shape_id_i(shape_id_t shape_id, void *data)
{
Expand Down Expand Up @@ -835,11 +846,15 @@ shape_id_i(shape_id_t shape_id, void *data)
dump_append(dc, "}\n");
}

/* :nodoc: */
static VALUE
objspace_dump_all(VALUE os, VALUE output, VALUE full, VALUE since, VALUE shapes)
dump_all_locked(void *args_p)
{
struct dump_config dc = {0,};
VALUE output = ((VALUE*)args_p)[0];
VALUE full = ((VALUE*)args_p)[1];
VALUE since = ((VALUE*)args_p)[2];
VALUE shapes = ((VALUE*)args_p)[3];

dump_output(&dc, output, full, since, shapes);

if (!dc.partial_dump || dc.since == 0) {
Expand All @@ -860,9 +875,23 @@ objspace_dump_all(VALUE os, VALUE output, VALUE full, VALUE since, VALUE shapes)

/* :nodoc: */
static VALUE
objspace_dump_shapes(VALUE os, VALUE output, VALUE shapes)
objspace_dump_all(VALUE os, VALUE output, VALUE full, VALUE since, VALUE shapes)
{
VALUE args[4];
args[0] = output;
args[1] = full;
args[2] = since;
args[3] = shapes;
return rb_vm_lock_with_barrier(dump_all_locked, (void*)args);
}

static VALUE
dump_shapes_locked(void *args_p)
{
struct dump_config dc = {0,};
VALUE output = ((VALUE*)args_p)[0];
VALUE shapes = ((VALUE*)args_p)[1];

dump_output(&dc, output, Qfalse, Qnil, shapes);

if (RTEST(shapes)) {
Expand All @@ -871,13 +900,26 @@ objspace_dump_shapes(VALUE os, VALUE output, VALUE shapes)
return dump_result(&dc);
}

/* :nodoc: */
static VALUE
objspace_dump_shapes(VALUE os, VALUE output, VALUE shapes)
{
VALUE args[2];
args[0] = output;
args[1] = shapes;
return rb_vm_lock_with_barrier(dump_shapes_locked, (void*)args);
}

void
Init_objspace_dump(VALUE rb_mObjSpace)
{
#undef rb_intern
#if 0
rb_mObjSpace = rb_define_module("ObjectSpace"); /* let rdoc know */
#endif
#ifdef HAVE_RB_EXT_RACTOR_SAFE
RB_EXT_RACTOR_SAFE(true);
#endif

rb_define_module_function(rb_mObjSpace, "_dump", objspace_dump, 2);
rb_define_module_function(rb_mObjSpace, "_dump_all", objspace_dump_all, 4);
Expand Down
8 changes: 4 additions & 4 deletions gems/bundled_gems
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ test-unit 3.7.3 https://github.com/test-unit/test-unit
rexml 3.4.4 https://github.com/ruby/rexml
rss 0.3.1 https://github.com/ruby/rss
net-ftp 0.3.9 https://github.com/ruby/net-ftp
net-imap 0.5.12 https://github.com/ruby/net-imap
net-imap 0.6.1 https://github.com/ruby/net-imap
net-pop 0.1.2 https://github.com/ruby/net-pop
net-smtp 0.5.1 https://github.com/ruby/net-smtp
matrix 0.4.3 https://github.com/ruby/matrix
prime 0.1.4 https://github.com/ruby/prime
rbs 3.9.5 https://github.com/ruby/rbs 22451ecbe262326176eb3915b64366712930685c # waiting for https://github.com/ruby/rbs/pull/2706
rbs 3.10.0.pre.2 https://github.com/ruby/rbs
typeprof 0.31.0 https://github.com/ruby/typeprof
debug 1.11.0 https://github.com/ruby/debug
racc 1.8.1 https://github.com/ruby/racc
mutex_m 0.3.0 https://github.com/ruby/mutex_m
getoptlong 0.2.1 https://github.com/ruby/getoptlong
base64 0.3.0 https://github.com/ruby/base64
bigdecimal 3.3.1 https://github.com/ruby/bigdecimal
bigdecimal 4.0.1 https://github.com/ruby/bigdecimal
observer 0.1.2 https://github.com/ruby/observer
abbrev 0.1.2 https://github.com/ruby/abbrev
resolv-replace 0.1.1 https://github.com/ruby/resolv-replace
Expand All @@ -41,7 +41,7 @@ benchmark 0.5.0 https://github.com/ruby/benchmark
logger 1.7.0 https://github.com/ruby/logger
rdoc 6.17.0 https://github.com/ruby/rdoc
win32ole 1.9.2 https://github.com/ruby/win32ole
irb 1.15.3 https://github.com/ruby/irb
irb 1.16.0 https://github.com/ruby/irb
reline 0.6.3 https://github.com/ruby/reline
readline 0.0.4 https://github.com/ruby/readline
fiddle 1.1.8 https://github.com/ruby/fiddle
40 changes: 2 additions & 38 deletions spec/ruby/library/bigdecimal/BigDecimal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,12 @@
end

it "accepts significant digits >= given precision" do
suppress_warning do
BigDecimal("3.1415923", 10).precs[1].should >= 10
end
BigDecimal("3.1415923", 10).should == BigDecimal("3.1415923")
end

it "determines precision from initial value" do
pi_string = "3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593014782083152134043"
suppress_warning {
BigDecimal(pi_string).precs[1]
}.should >= pi_string.size-1
BigDecimal(pi_string).precision.should == pi_string.size-1
end

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

it "has the expected precision on the LHS" do
suppress_warning { @a.precs[0] }.should == 18
end

it "has the expected maximum precision on the LHS" do
suppress_warning { @a.precs[1] }.should == 27
end

it "produces the expected result when done via Float" do
(Float(@a) - Float(@b)).to_s.should == "-6.666596163995564e-10"
end
Expand All @@ -226,34 +214,10 @@ def to_s; "cheese"; end

# Check underlying methods work as we understand

it "BigDecimal precision is the number of digits rounded up to a multiple of nine" do
1.upto(100) do |n|
b = BigDecimal('4' * n)
precs, _ = suppress_warning { b.precs }
(precs >= 9).should be_true
(precs >= n).should be_true
(precs % 9).should == 0
end
suppress_warning { BigDecimal('NaN').precs[0] }.should == 9
end

it "BigDecimal maximum precision is nine more than precision except for abnormals" do
1.upto(100) do |n|
b = BigDecimal('4' * n)
precs, max = suppress_warning { b.precs }
max.should == precs + 9
end
suppress_warning { BigDecimal('NaN').precs[1] }.should == 9
end

it "BigDecimal(Rational, 18) produces the result we expect" do
BigDecimal(@b, 18).to_s.should == "0.166666666666666667e3"
end

it "BigDecimal(Rational, BigDecimal.precs[0]) produces the result we expect" do
BigDecimal(@b, suppress_warning { @a.precs[0] }).to_s.should == "0.166666666666666667e3"
end

# Check the top-level expression works as we expect

it "produces a BigDecimal" do
Expand Down
61 changes: 43 additions & 18 deletions spec/ruby/library/bigdecimal/divmod_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ class BigDecimal
end
end

it_behaves_like :bigdecimal_modulo, :mod_part_of_divmod
version_is BigDecimal::VERSION, ""..."4.0.0" do
it_behaves_like :bigdecimal_modulo, :mod_part_of_divmod
end

it "raises ZeroDivisionError if other is zero" do
bd5667 = BigDecimal("5667.19")

zero = BigDecimal("0")
-> { bd5667.mod_part_of_divmod(0) }.should raise_error(ZeroDivisionError)
-> { bd5667.mod_part_of_divmod(BigDecimal("0")) }.should raise_error(ZeroDivisionError)
-> { @zero.mod_part_of_divmod(@zero) }.should raise_error(ZeroDivisionError)
-> { zero.mod_part_of_divmod(zero) }.should raise_error(ZeroDivisionError)
end
end

Expand Down Expand Up @@ -73,14 +75,25 @@ class BigDecimal
@zeroes = [@zero, @zero_pos, @zero_neg]
end

it "divides value, returns an array" do
res = @a.divmod(5)
res.kind_of?(Array).should == true
version_is BigDecimal::VERSION, ""..."4.0.0" do
it "divides value, returns [BigDecimal, BigDecimal]" do
res = @a.divmod(5)
res.kind_of?(Array).should == true
DivmodSpecs.check_both_bigdecimal(res)
end
end

version_is BigDecimal::VERSION, "4.0.0" do
it "divides value, returns [Integer, BigDecimal]" do
res = @a.divmod(5)
res.kind_of?(Array).should == true
res[0].kind_of?(Integer).should == true
res[1].kind_of?(BigDecimal).should == true
end
end

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

Expand Down Expand Up @@ -123,17 +136,27 @@ class BigDecimal
values_and_zeroes.each do |val1|
values.each do |val2|
res = val1.divmod(val2)
DivmodSpecs.check_both_bigdecimal(res)
res[0].should == ((val1/val2).floor)
res[1].should == (val1 - res[0] * val2)
end
end
end

it "returns an array of two NaNs if NaN is involved" do
(@special_vals + @regular_vals + @zeroes).each do |val|
DivmodSpecs.check_both_nan(val.divmod(@nan))
DivmodSpecs.check_both_nan(@nan.divmod(val))
version_is BigDecimal::VERSION, "4.0.0" do
it "raise FloatDomainError error if NaN is involved" do
(@special_vals + @regular_vals + @zeroes).each do |val|
-> { val.divmod(@nan) }.should raise_error(FloatDomainError)
-> { @nan.divmod(val) }.should raise_error(FloatDomainError)
end
end
end

version_is BigDecimal::VERSION, ""..."4.0.0" do
it "returns an array of two NaNs if NaN is involved" do
(@special_vals + @regular_vals + @zeroes).each do |val|
DivmodSpecs.check_both_nan(val.divmod(@nan))
DivmodSpecs.check_both_nan(@nan.divmod(val))
end
end
end

Expand All @@ -145,12 +168,14 @@ class BigDecimal
end
end

it "returns an array of Infinity and NaN if the dividend is Infinity" do
@regular_vals.each do |val|
array = @infinity.divmod(val)
array.length.should == 2
array[0].infinite?.should == (val > 0 ? 1 : -1)
array[1].should.nan?
version_is BigDecimal::VERSION, ""..."4.0.0" do
it "returns an array of Infinity and NaN if the dividend is Infinity" do
@regular_vals.each do |val|
array = @infinity.divmod(val)
array.length.should == 2
array[0].infinite?.should == (val > 0 ? 1 : -1)
array[1].should.nan?
end
end
end

Expand Down
Loading