diff --git a/NEWS.md b/NEWS.md index b5071761976d05..2435498da9af12 100644 --- a/NEWS.md +++ b/NEWS.md @@ -37,9 +37,6 @@ Note: We're only listing outstanding class updates. * `Array#rfind` has been added as a more efficient alternative to `array.reverse_each.find` [[Feature #21678]] * `Array#find` has been added as a more efficient override of `Enumerable#find` [[Feature #21678]] - * `Array#pack` accepts a new format `R` and `r` for unpacking unsigned - and signed LEB128 encoded integers. [[Feature #21785]] - * Binding * `Binding#local_variables` does no longer include numbered parameters. @@ -267,9 +264,6 @@ Note: We're only listing outstanding class updates. * `String#strip`, `strip!`, `lstrip`, `lstrip!`, `rstrip`, and `rstrip!` are extended to accept `*selectors` arguments. [[Feature #21552]] - * `String#unpack` accepts a new format `R` and `r` for unpacking unsigned - and signed LEB128 encoded integers. [[Feature #21785]] - * Thread * Introduce support for `Thread#raise(cause:)` argument similar to @@ -575,5 +569,4 @@ A lot of work has gone into making Ractors more stable, performant, and usable. [Feature #21678]: https://bugs.ruby-lang.org/issues/21678 [Bug #21698]: https://bugs.ruby-lang.org/issues/21698 [Feature #21701]: https://bugs.ruby-lang.org/issues/21701 -[Feature #21785]: https://bugs.ruby-lang.org/issues/21785 [Bug #21789]: https://bugs.ruby-lang.org/issues/21789 diff --git a/array.c b/array.c index 27b84249bf44fe..e13239ad3daaa1 100644 --- a/array.c +++ b/array.c @@ -2102,9 +2102,7 @@ rb_ary_fetch(int argc, VALUE *argv, VALUE ary) * * If no such element is found, calls +if_none_proc+ and returns its return value. * - * [1, 3, 5].find(proc {false}) {|element| element > 12} # => false - * [[:foo, 0], [:bar, 1], [:baz, 2]].find {|key, value| key.start_with?('b') } # => [:bar, 1] - * [[:foo, 0], [:bar, 1], [:baz, 2]].find(proc {[]}) {|key, value| key.start_with?('c') } # => [] + * [1, 3, 5].find(proc {-1}) {|element| element > 12} # => -1 * * With no block given, returns an Enumerator. * @@ -2140,16 +2138,14 @@ rb_ary_find(int argc, VALUE *argv, VALUE ary) * Returns the last element for which the block returns a truthy value. * * With a block given, calls the block with successive elements of the array in - * reverse order; returns the last element for which the block returns a truthy + * reverse order; returns the first element for which the block returns a truthy * value: * - * (0..9).rfind {|element| element < 5} # => 4 + * [1, 2, 3, 4, 5, 6].rfind {|element| element < 5} # => 4 * * If no such element is found, calls +if_none_proc+ and returns its return value. * - * (0..9).rfind(proc {false}) {|element| element < -2} # => false - * {foo: 0, bar: 1, baz: 2}.rfind {|key, value| key.start_with?('b') } # => [:baz, 2] - * {foo: 0, bar: 1, baz: 2}.rfind(proc {[]}) {|key, value| key.start_with?('c') } # => [] + * [1, 2, 3, 4].rfind(proc {0}) {|element| element < -2} # => 0 * * With no block given, returns an Enumerator. * diff --git a/cont.c b/cont.c index 0087994730419e..b33c1462bf3ea1 100644 --- a/cont.c +++ b/cont.c @@ -3246,28 +3246,37 @@ rb_fiber_raise(VALUE fiber, int argc, VALUE *argv) /* * call-seq: - * fiber.raise -> obj - * fiber.raise(string) -> obj - * fiber.raise(exception [, string [, array]]) -> obj + * raise(exception, message = exception.to_s, backtrace = nil, cause: $!) + * raise(message = nil, cause: $!) * * Raises an exception in the fiber at the point at which the last - * +Fiber.yield+ was called. If the fiber has not been started or has + * +Fiber.yield+ was called. + * + * f = Fiber.new { + * puts "Before the yield" + * Fiber.yield 1 # -- exception will be raised here + * puts "After the yield" + * } + * + * p f.resume + * f.raise "Gotcha" + * + * Output + * + * Before the first yield + * 1 + * t.rb:8:in 'Fiber.yield': Gotcha (RuntimeError) + * from t.rb:8:in 'block in
' + * + * If the fiber has not been started or has * already run to completion, raises +FiberError+. If the fiber is * yielding, it is resumed. If it is transferring, it is transferred into. * But if it is resuming, raises +FiberError+. * - * With no arguments, raises a +RuntimeError+. With a single +String+ - * argument, raises a +RuntimeError+ with the string as a message. Otherwise, - * the first parameter should be the name of an +Exception+ class (or an - * object that returns an +Exception+ object when sent an +exception+ - * message). The optional second parameter sets the message associated with - * the exception, and the third parameter is an array of callback information. - * Exceptions are caught by the +rescue+ clause of begin...end - * blocks. - * * Raises +FiberError+ if called on a Fiber belonging to another +Thread+. * - * See Kernel#raise for more information. + * See Kernel#raise for more information on arguments. + * */ static VALUE rb_fiber_m_raise(int argc, VALUE *argv, VALUE self) diff --git a/doc/language/box.md b/doc/language/box.md index aebce7188b3179..abc6af868fc470 100644 --- a/doc/language/box.md +++ b/doc/language/box.md @@ -11,7 +11,7 @@ Ruby Box is designed to provide separated spaces in a Ruby process, to isolate a ## TODOs -* Add the loaded namespace on iseq to check if another namespace tries running the iseq (add a field only when VM_CHECK_MODE?) +* Add the loaded box on iseq to check if another box tries running the iseq (add a field only when VM_CHECK_MODE?) * Assign its own TOPLEVEL_BINDING in boxes * Fix calling `warn` in boxes to refer `$VERBOSE` and `Warning.warn` in the box * Make an internal data container class `Ruby::Box::Entry` invisible @@ -22,7 +22,7 @@ Ruby Box is designed to provide separated spaces in a Ruby process, to isolate a ### Enabling Ruby Box First, an environment variable should be set at the ruby process bootup: `RUBY_BOX=1`. -The only valid value is `1` to enable namespace. Other values (or unset `RUBY_BOX`) means disabling namespace. And setting the value after Ruby program starts doesn't work. +The only valid value is `1` to enable Ruby Box. Other values (or unset `RUBY_BOX`) means disabling Ruby Box. And setting the value after Ruby program starts doesn't work. ### Using Ruby Box @@ -75,7 +75,7 @@ There are two box types: There is the root box, just a single box in a Ruby process. Ruby bootstrap runs in the root box, and all builtin classes/modules are defined in the root box. (See "Builtin classes and modules".) -User boxes are to run user-written programs and libraries loaded from user programs. The user's main program (specified by the `ruby` command line argument) is executed in the "main" box, which is a user namespace automatically created at the end of Ruby's bootstrap, copied from the root box. +User boxes are to run user-written programs and libraries loaded from user programs. The user's main program (specified by the `ruby` command line argument) is executed in the "main" box, which is a user box automatically created at the end of Ruby's bootstrap, copied from the root box. When `Ruby::Box.new` is called, an "optional" box (a user, non-main box) is created, copied from the root box. All user boxes are flat, copied from the root box. diff --git a/doc/language/character_selectors.rdoc b/doc/language/character_selectors.rdoc index 47cf242be7382b..20685b8392b655 100644 --- a/doc/language/character_selectors.rdoc +++ b/doc/language/character_selectors.rdoc @@ -14,6 +14,8 @@ Each of these instance methods accepts one or more character selectors: - String#delete!(*selectors): returns +self+ or +nil+. - String#squeeze(*selectors): returns a new string. - String#squeeze!(*selectors): returns +self+ or +nil+. +- String#strip(*selectors): returns a new string. +- String#strip!(*selectors): returns +self+ or +nil+. A character selector identifies zero or more characters in +self+ that are to be operands for the method. @@ -79,6 +81,8 @@ These instance methods accept multiple character selectors: - String#delete!(*selectors): returns +self+ or +nil+. - String#squeeze(*selectors): returns a new string. - String#squeeze!(*selectors): returns +self+ or +nil+. +- String#strip(*selectors): returns a new string. +- String#strip!(*selectors): returns +self+ or +nil+. In effect, the given selectors are formed into a single selector consisting of only those characters common to _all_ of the given selectors. diff --git a/doc/language/packed_data.rdoc b/doc/language/packed_data.rdoc index 97079f7f08dd8f..f7cb4dbf74d99b 100644 --- a/doc/language/packed_data.rdoc +++ b/doc/language/packed_data.rdoc @@ -53,8 +53,6 @@ These tables summarize the directives for packing and unpacking. U | UTF-8 character w | BER-compressed integer - R | LEB128 encoded unsigned integer - r | LEB128 encoded signed integer === For Floats diff --git a/doc/syntax/calling_methods.rdoc b/doc/syntax/calling_methods.rdoc index bf5916e99aa071..76babcc3dcd969 100644 --- a/doc/syntax/calling_methods.rdoc +++ b/doc/syntax/calling_methods.rdoc @@ -355,9 +355,8 @@ as one argument: # Prints the object itself: # # -This allows to handle one or many arguments polymorphically. Note also that +nil+ -has NilClass#to_a defined to return an empty array, so conditional unpacking is -possible: +This allows to handle one or many arguments polymorphically. Note also that *nil +is unpacked to an empty list of arguments, so conditional unpacking is possible: my_method(*(some_arguments if some_condition?)) diff --git a/enumerator.c b/enumerator.c index 5514d76dace3d4..89ec5035305753 100644 --- a/enumerator.c +++ b/enumerator.c @@ -1230,6 +1230,24 @@ enumerator_inspect(VALUE obj) * (1..100).to_a.permutation(4).size # => 94109400 * loop.size # => Float::INFINITY * (1..100).drop_while.size # => nil + * + * Note that enumerator size might be inaccurate, and should be rather treated as a hint. + * For example, there is no check that the size provided to ::new is accurate: + * + * e = Enumerator.new(5) { |y| 2.times { y << it} } + * e.size # => 5 + * e.to_a.size # => 2 + * + * Another example is an enumerator created by ::produce without a +size+ argument. + * Such enumerators return +Infinity+ for size, but this is inaccurate if the passed + * block raises StopIteration: + * + * e = Enumerator.produce(1) { it + 1 } + * e.size # => Infinity + * + * e = Enumerator.produce(1) { it > 3 ? raise(StopIteration) : it + 1 } + * e.size # => Infinity + * e.to_a.size # => 4 */ static VALUE @@ -3051,6 +3069,12 @@ producer_size(VALUE obj, VALUE args, VALUE eobj) * File.dirname(it) * } * traverser.size # => 4 + * + * # Finite enumerator with unknown size + * calendar = Enumerator.produce(Date.today, size: nil) { + * it.monday? ? raise(StopIteration) : it + 1 + * } + * calendar.size # => nil */ static VALUE enumerator_s_produce(int argc, VALUE *argv, VALUE klass) diff --git a/eval.c b/eval.c index 0c80872bee76e5..deadd5dd6414fb 100644 --- a/eval.c +++ b/eval.c @@ -922,6 +922,9 @@ rb_f_raise(int argc, VALUE *argv) * With argument +exception+ not given, * argument +message+ and keyword argument +cause+ may be given, * but argument +backtrace+ may not be given. + * + * +cause+ can not be given as an only argument. + * */ static VALUE diff --git a/pack.c b/pack.c index 6f68b13ccac6c4..3a5c1bfb9677cf 100644 --- a/pack.c +++ b/pack.c @@ -667,56 +667,6 @@ pack_pack(rb_execution_context_t *ec, VALUE ary, VALUE fmt, VALUE buffer) } break; - case 'r': /* r for SLEB128 encoding (signed) */ - case 'R': /* R for ULEB128 encoding (unsigned) */ - { - int pack_flags = INTEGER_PACK_LITTLE_ENDIAN; - - if (type == 'r') { - pack_flags |= INTEGER_PACK_2COMP; - } - - while (len-- > 0) { - size_t numbytes; - int sign; - char *cp; - - from = NEXTFROM; - from = rb_to_int(from); - numbytes = rb_absint_numwords(from, 7, NULL); - if (numbytes == 0) - numbytes = 1; - VALUE buf = rb_str_new(NULL, numbytes); - - sign = rb_integer_pack(from, RSTRING_PTR(buf), RSTRING_LEN(buf), 1, 1, pack_flags); - - if (sign < 0 && type == 'R') { - rb_raise(rb_eArgError, "can't encode negative numbers in ULEB128"); - } - - if (type == 'r') { - /* Check if we need an extra byte for sign extension */ - unsigned char last_byte = (unsigned char)RSTRING_PTR(buf)[numbytes - 1]; - if ((sign >= 0 && (last_byte & 0x40)) || /* positive but sign bit set */ - (sign < 0 && !(last_byte & 0x40))) { /* negative but sign bit clear */ - /* Need an extra byte */ - rb_str_resize(buf, numbytes + 1); - RSTRING_PTR(buf)[numbytes] = sign < 0 ? 0x7f : 0x00; - numbytes++; - } - } - - cp = RSTRING_PTR(buf); - while (1 < numbytes) { - *cp |= 0x80; - cp++; - numbytes--; - } - - rb_str_buf_cat(res, RSTRING_PTR(buf), RSTRING_LEN(buf)); - } - } - break; case 'u': /* uuencoded string */ case 'm': /* base64 encoded string */ from = NEXTFROM; @@ -1608,39 +1558,6 @@ pack_unpack_internal(VALUE str, VALUE fmt, enum unpack_mode mode, long offset) } break; - case 'r': - case 'R': - { - int pack_flags = INTEGER_PACK_LITTLE_ENDIAN; - - if (type == 'r') { - pack_flags |= INTEGER_PACK_2COMP; - } - char *s0 = s; - while (len > 0 && s < send) { - if (*s & 0x80) { - s++; - } - else { - s++; - UNPACK_PUSH(rb_integer_unpack(s0, s-s0, 1, 1, pack_flags)); - len--; - s0 = s; - } - } - /* Handle incomplete value and remaining expected values with nil (only if not using *) */ - if (!star) { - if (s0 != s && len > 0) { - UNPACK_PUSH(Qnil); - len--; - } - while (len-- > 0) { - UNPACK_PUSH(Qnil); - } - } - } - break; - case 'w': { char *s0 = s; diff --git a/range.c b/range.c index f82d1a316ddd7d..82c252e3ef50cd 100644 --- a/range.c +++ b/range.c @@ -1018,6 +1018,20 @@ range_to_a(VALUE range) return rb_call_super(0, 0); } +/* + * call-seq: + * to_set -> set + * + * Returns a set containing the elements in +self+, if a finite collection; + * raises an exception otherwise. + * + * (1..4).to_set # => Set[1, 2, 3, 4] + * (1...4).to_set # => Set[1, 2, 3] + * + * (1..).to_set + * # in 'Range#to_set': cannot convert endless range to a set (RangeError) + * + */ static VALUE range_to_set(int argc, VALUE *argv, VALUE range) { diff --git a/spec/ruby/core/array/pack/r_spec.rb b/spec/ruby/core/array/pack/r_spec.rb deleted file mode 100644 index 22be6fa6400cfa..00000000000000 --- a/spec/ruby/core/array/pack/r_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require_relative '../../../spec_helper' -require_relative '../fixtures/classes' -require_relative 'shared/basic' -require_relative 'shared/numeric_basic' -require_relative 'shared/integer' - -ruby_version_is "4.0" do - describe "Array#pack with format 'R'" do - it_behaves_like :array_pack_basic, 'R' - it_behaves_like :array_pack_basic_non_float, 'R' - it_behaves_like :array_pack_arguments, 'R' - it_behaves_like :array_pack_numeric_basic, 'R' - it_behaves_like :array_pack_integer, 'R' - end - - describe "Array#pack with format 'r'" do - it_behaves_like :array_pack_basic, 'r' - it_behaves_like :array_pack_basic_non_float, 'r' - it_behaves_like :array_pack_arguments, 'r' - it_behaves_like :array_pack_numeric_basic, 'r' - it_behaves_like :array_pack_integer, 'r' - end -end diff --git a/spec/ruby/core/array/pack/shared/basic.rb b/spec/ruby/core/array/pack/shared/basic.rb index 77d7f2f71c0873..ebd9f75d9dc66a 100644 --- a/spec/ruby/core/array/pack/shared/basic.rb +++ b/spec/ruby/core/array/pack/shared/basic.rb @@ -37,7 +37,7 @@ # NOTE: it's just a plan of the Ruby core team it "warns that a directive is unknown" do # additional directive ('a') is required for the X directive - -> { [@obj, @obj].pack("a K" + pack_format) }.should complain(/unknown pack directive 'K'/) + -> { [@obj, @obj].pack("a R" + pack_format) }.should complain(/unknown pack directive 'R'/) -> { [@obj, @obj].pack("a 0" + pack_format) }.should complain(/unknown pack directive '0'/) -> { [@obj, @obj].pack("a :" + pack_format) }.should complain(/unknown pack directive ':'/) end @@ -48,7 +48,7 @@ # NOTE: Added this case just to not forget about the decision in the ticket it "raise ArgumentError when a directive is unknown" do # additional directive ('a') is required for the X directive - -> { [@obj, @obj].pack("a K" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive 'K'/) + -> { [@obj, @obj].pack("a R" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive 'R'/) -> { [@obj, @obj].pack("a 0" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive '0'/) -> { [@obj, @obj].pack("a :" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive ':'/) end diff --git a/spec/ruby/core/string/unpack/shared/basic.rb b/spec/ruby/core/string/unpack/shared/basic.rb index 0ac2a951ed7220..b37a447683a95c 100644 --- a/spec/ruby/core/string/unpack/shared/basic.rb +++ b/spec/ruby/core/string/unpack/shared/basic.rb @@ -12,7 +12,7 @@ ruby_version_is "3.3" do # https://bugs.ruby-lang.org/issues/19150 it 'raise ArgumentError when a directive is unknown' do - -> { "abcdefgh".unpack("a K" + unpack_format) }.should raise_error(ArgumentError, /unknown unpack directive 'K'/) + -> { "abcdefgh".unpack("a R" + unpack_format) }.should raise_error(ArgumentError, /unknown unpack directive 'R'/) -> { "abcdefgh".unpack("a 0" + unpack_format) }.should raise_error(ArgumentError, /unknown unpack directive '0'/) -> { "abcdefgh".unpack("a :" + unpack_format) }.should raise_error(ArgumentError, /unknown unpack directive ':'/) end diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb index 9c40cfaa204f86..ca089f09c3dc4b 100644 --- a/test/ruby/test_pack.rb +++ b/test/ruby/test_pack.rb @@ -936,116 +936,4 @@ class Array assert_equal "oh no", v end; end - - def test_unpack_broken_R - assert_equal([nil], "\xFF".unpack("R")) - assert_nil("\xFF".unpack1("R")) - assert_equal([nil], "\xFF".unpack("r")) - assert_nil("\xFF".unpack1("r")) - - bytes = [256].pack("r") - assert_equal([256, nil, nil, nil], (bytes + "\xFF").unpack("rrrr")) - - bytes = [256].pack("R") - assert_equal([256, nil, nil, nil], (bytes + "\xFF").unpack("RRRR")) - - assert_equal([], "\xFF".unpack("R*")) - assert_equal([], "\xFF".unpack("r*")) - end - - def test_pack_unpack_R - # ULEB128 encoding (unsigned) - assert_equal("\x00", [0].pack("R")) - assert_equal("\x01", [1].pack("R")) - assert_equal("\x7f", [127].pack("R")) - assert_equal("\x80\x01", [128].pack("R")) - assert_equal("\xff\x7f", [0x3fff].pack("R")) - assert_equal("\x80\x80\x01", [0x4000].pack("R")) - assert_equal("\xff\xff\xff\xff\x0f", [0xffffffff].pack("R")) - assert_equal("\x80\x80\x80\x80\x10", [0x100000000].pack("R")) - assert_equal("\xff\xff\xff\xff\xff\xff\xff\xff\xff\x01", [0xffff_ffff_ffff_ffff].pack("R")) - assert_equal("\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x1f", [0xffff_ffff_ffff_ffff_ffff_ffff].pack("R")) - - # Multiple values - assert_equal("\x01\x02", [1, 2].pack("R*")) - assert_equal("\x7f\x80\x01", [127, 128].pack("R*")) - - # Negative numbers should raise an error - assert_raise(ArgumentError) { [-1].pack("R") } - assert_raise(ArgumentError) { [-100].pack("R") } - - # Unpack tests - assert_equal([0], "\x00".unpack("R")) - assert_equal([1], "\x01".unpack("R")) - assert_equal([127], "\x7f".unpack("R")) - assert_equal([128], "\x80\x01".unpack("R")) - assert_equal([0x3fff], "\xff\x7f".unpack("R")) - assert_equal([0x4000], "\x80\x80\x01".unpack("R")) - assert_equal([0xffffffff], "\xff\xff\xff\xff\x0f".unpack("R")) - assert_equal([0x100000000], "\x80\x80\x80\x80\x10".unpack("R")) - assert_equal([0xffff_ffff_ffff_ffff], "\xff\xff\xff\xff\xff\xff\xff\xff\xff\x01".unpack("R")) - assert_equal([0xffff_ffff_ffff_ffff_ffff_ffff].pack("R"), "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x1f") - - # Multiple values - assert_equal([1, 2], "\x01\x02".unpack("R*")) - assert_equal([127, 128], "\x7f\x80\x01".unpack("R*")) - - # Round-trip test - values = [0, 1, 127, 128, 0x3fff, 0x4000, 0xffffffff, 0x100000000] - assert_equal(values, values.pack("R*").unpack("R*")) - end - - def test_pack_unpack_r - # SLEB128 encoding (signed) - assert_equal("\x00", [0].pack("r")) - assert_equal("\x01", [1].pack("r")) - assert_equal("\x7f", [-1].pack("r")) - assert_equal("\x7e", [-2].pack("r")) - assert_equal("\xff\x00", [127].pack("r")) - assert_equal("\x80\x01", [128].pack("r")) - assert_equal("\x81\x7f", [-127].pack("r")) - assert_equal("\x80\x7f", [-128].pack("r")) - - # Larger positive numbers - assert_equal("\xff\xff\x00", [0x3fff].pack("r")) - assert_equal("\x80\x80\x01", [0x4000].pack("r")) - - # Larger negative numbers - assert_equal("\x81\x80\x7f", [-0x3fff].pack("r")) - assert_equal("\x80\x80\x7f", [-0x4000].pack("r")) - - # Very large numbers - assert_equal("\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x1F", [0xffff_ffff_ffff_ffff_ffff_ffff].pack("r")) - assert_equal("\x81\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80`", [-0xffff_ffff_ffff_ffff_ffff_ffff].pack("r")) - - # Multiple values - assert_equal("\x00\x01\x7f", [0, 1, -1].pack("r*")) - - # Unpack tests - assert_equal([0], "\x00".unpack("r")) - assert_equal([1], "\x01".unpack("r")) - assert_equal([-1], "\x7f".unpack("r")) - assert_equal([-2], "\x7e".unpack("r")) - assert_equal([127], "\xff\x00".unpack("r")) - assert_equal([128], "\x80\x01".unpack("r")) - assert_equal([-127], "\x81\x7f".unpack("r")) - assert_equal([-128], "\x80\x7f".unpack("r")) - - # Larger numbers - assert_equal([0x3fff], "\xff\xff\x00".unpack("r")) - assert_equal([0x4000], "\x80\x80\x01".unpack("r")) - assert_equal([-0x3fff], "\x81\x80\x7f".unpack("r")) - assert_equal([-0x4000], "\x80\x80\x7f".unpack("r")) - - # Very large numbers - assert_equal("\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x1f", [0xffff_ffff_ffff_ffff_ffff_ffff].pack("r")) - assert_equal("\x81\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80`", [-0xffff_ffff_ffff_ffff_ffff_ffff].pack("r")) - - # Multiple values - assert_equal([0, 1, -1], "\x00\x01\x7f".unpack("r*")) - - # Round-trip test - values = [0, 1, -1, 127, -127, 128, -128, 0x3fff, -0x3fff, 0x4000, -0x4000] - assert_equal(values, values.pack("r*").unpack("r*")) - end end diff --git a/test/rubygems/test_gem_commands_install_command.rb b/test/rubygems/test_gem_commands_install_command.rb index 72ca9d8262583a..d2ca933a632c7d 100644 --- a/test/rubygems/test_gem_commands_install_command.rb +++ b/test/rubygems/test_gem_commands_install_command.rb @@ -1610,7 +1610,7 @@ def test_pass_down_the_job_option_to_make gem_make_out = File.read(File.join(gemspec.extension_dir, "gem_make.out")) if vc_windows? && nmake_found? - refute_includes(gem_make_out, "-j4") + refute_includes(gem_make_out, " -j4") else assert_includes(gem_make_out, "make -j4") end diff --git a/thread.c b/thread.c index 788a0e9ad791a2..e66352c03f6c4a 100644 --- a/thread.c +++ b/thread.c @@ -2908,12 +2908,11 @@ rb_thread_fd_close(int fd) /* * call-seq: - * thr.raise - * thr.raise(string) - * thr.raise(exception [, string [, array]]) + * raise(exception, message = exception.to_s, backtrace = nil, cause: $!) + * raise(message = nil, cause: $!) * * Raises an exception from the given thread. The caller does not have to be - * +thr+. See Kernel#raise for more information. + * +thr+. See Kernel#raise for more information on arguments. * * Thread.abort_on_exception = true * a = Thread.new { sleep(200) }