From d0b72429a93e54f1f956b4aedfc25c57dc7001aa Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 16 Dec 2025 09:10:45 -0800 Subject: Add support for signed and unsigned LEB128 to pack/unpack. This commit adds a new pack format command `R` and `r` for unsigned and signed LEB128 encoding. The "r" mnemonic is because this is a "vaRiable" length encoding scheme. LEB128 is used in various formats including DWARF, WebAssembly, MQTT, and Protobuf. [Feature #21785] --- spec/ruby/core/array/pack/shared/basic.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/ruby/core/array/pack/shared/basic.rb') diff --git a/spec/ruby/core/array/pack/shared/basic.rb b/spec/ruby/core/array/pack/shared/basic.rb index ebd9f75d9d..77d7f2f71c 100644 --- a/spec/ruby/core/array/pack/shared/basic.rb +++ b/spec/ruby/core/array/pack/shared/basic.rb @@ -37,7 +37,7 @@ describe :array_pack_basic_non_float, shared: true do # 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 R" + pack_format) }.should complain(/unknown pack directive 'R'/) + -> { [@obj, @obj].pack("a K" + pack_format) }.should complain(/unknown pack directive 'K'/) -> { [@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 @@ describe :array_pack_basic_non_float, shared: true do # 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 R" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive 'R'/) + -> { [@obj, @obj].pack("a K" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive 'K'/) -> { [@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 -- cgit v1.2.3