diff options
| author | Aaron Patterson <tenderlove@ruby-lang.org> | 2025-12-16 09:10:45 -0800 |
|---|---|---|
| committer | Aaron Patterson <aaron.patterson@gmail.com> | 2025-12-18 14:42:47 -0800 |
| commit | d0b72429a93e54f1f956b4aedfc25c57dc7001aa (patch) | |
| tree | 1e4303fd43d1b99972922bfdbb61fee6836b7bc5 /spec/ruby/core/array/pack/shared/basic.rb | |
| parent | 73e930f9f911cf71ecb416c3112a7818bae41cd6 (diff) | |
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]
Diffstat (limited to 'spec/ruby/core/array/pack/shared/basic.rb')
| -rw-r--r-- | spec/ruby/core/array/pack/shared/basic.rb | 4 |
1 files changed, 2 insertions, 2 deletions
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 |
