<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/test/ruby/test_array.rb, branch v4.0.4</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>Array#rfind</title>
<updated>2025-12-12T18:35:30+00:00</updated>
<author>
<name>Kevin Newton</name>
<email>kddnewton@gmail.com</email>
</author>
<published>2025-11-14T16:31:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=6147b695870ce82ee3ad5305ce095b63889b8d9d'/>
<id>6147b695870ce82ee3ad5305ce095b63889b8d9d</id>
<content type='text'>
Implement Array#rfind, which is the same as find except from the
other side of the Array. Also implemented Array#find (as opposed to
the generic one on Enumerable because it is significantly faster
and to keep the implementations together.

[Feature #21678]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Implement Array#rfind, which is the same as find except from the
other side of the Array. Also implemented Array#find (as opposed to
the generic one on Enumerable because it is significantly faster
and to keep the implementations together.

[Feature #21678]
</pre>
</div>
</content>
</entry>
<entry>
<title>Update comments for pack/unpack tests [ci skip]</title>
<updated>2025-07-27T15:06:44+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2025-07-27T15:06:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a9eed306aad6b3733ce6a7b880cd10d12acb8b4b'/>
<id>a9eed306aad6b3733ce6a7b880cd10d12acb8b4b</id>
<content type='text'>
More comprehensive pack/unpack tests are in test_pack.rb.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
More comprehensive pack/unpack tests are in test_pack.rb.
</pre>
</div>
</content>
</entry>
<entry>
<title>[Feature #20702] Tests for Array#fetch_values</title>
<updated>2025-03-18T08:55:46+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2025-03-18T08:55:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c7f31c88aeed45607d2abc6b641ad2ccfd77e240'/>
<id>c7f31c88aeed45607d2abc6b641ad2ccfd77e240</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Add out of range tests of random number generator</title>
<updated>2025-02-02T15:27:43+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2025-02-02T15:27:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=581d85058cf638f2f8ad87391dccc5c7708d597b'/>
<id>581d85058cf638f2f8ad87391dccc5c7708d597b</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Optimize instructions when creating an array just to call `include?` (#12123)</title>
<updated>2024-11-26T19:31:08+00:00</updated>
<author>
<name>Randy Stauner</name>
<email>randy.stauner@shopify.com</email>
</author>
<published>2024-11-26T19:31:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1dd40ec18a55ff46f52d0ba44ff5d7923f57c08f'/>
<id>1dd40ec18a55ff46f52d0ba44ff5d7923f57c08f</id>
<content type='text'>
* Add opt_duparray_send insn to skip the allocation on `#include?`

If the method isn't going to modify the array we don't need to copy it.
This avoids the allocation / array copy for things like `[:a, :b].include?(x)`.

This adds a BOP for include? and tracks redefinition for it on Array.

Co-authored-by: Andrew Novoselac &lt;andrew.novoselac@shopify.com&gt;

* YJIT: Implement opt_duparray_send include_p

Co-authored-by: Andrew Novoselac &lt;andrew.novoselac@shopify.com&gt;

* Update opt_newarray_send to support simple forms of include?(arg)

Similar to opt_duparray_send but for non-static arrays.

* YJIT: Implement opt_newarray_send include_p

---------

Co-authored-by: Andrew Novoselac &lt;andrew.novoselac@shopify.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Add opt_duparray_send insn to skip the allocation on `#include?`

If the method isn't going to modify the array we don't need to copy it.
This avoids the allocation / array copy for things like `[:a, :b].include?(x)`.

This adds a BOP for include? and tracks redefinition for it on Array.

Co-authored-by: Andrew Novoselac &lt;andrew.novoselac@shopify.com&gt;

* YJIT: Implement opt_duparray_send include_p

Co-authored-by: Andrew Novoselac &lt;andrew.novoselac@shopify.com&gt;

* Update opt_newarray_send to support simple forms of include?(arg)

Similar to opt_duparray_send but for non-static arrays.

* YJIT: Implement opt_newarray_send include_p

---------

Co-authored-by: Andrew Novoselac &lt;andrew.novoselac@shopify.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>Uncomment test accidentally commented in 1656350</title>
<updated>2024-08-22T23:47:40+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-08-22T23:47:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=fdba458e85bc66f35194f15a55aa8c27a4b5ce4a'/>
<id>fdba458e85bc66f35194f15a55aa8c27a4b5ce4a</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Don't use gc_impl.h inside of gc/gc.h</title>
<updated>2024-08-22T17:50:17+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-08-21T19:20:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=165635049a2f5af83efe2bd64b08e7b59e925e18'/>
<id>165635049a2f5af83efe2bd64b08e7b59e925e18</id>
<content type='text'>
Using gc_impl.h inside of gc/gc.h will cause gc/gc.h to use the functions
in gc/default.c when builing with shared GC support because gc/gc.h is
included into gc.c before the rb_gc_impl functions are overridden by the
preprocessor.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Using gc_impl.h inside of gc/gc.h will cause gc/gc.h to use the functions
in gc/default.c when builing with shared GC support because gc/gc.h is
included into gc.c before the rb_gc_impl functions are overridden by the
preprocessor.
</pre>
</div>
</content>
</entry>
<entry>
<title>array.c: Remove outdated assertions</title>
<updated>2024-07-03T15:16:17+00:00</updated>
<author>
<name>Jean Boussier</name>
<email>jean.boussier@gmail.com</email>
</author>
<published>2024-07-03T14:17:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=786cf9db488dd83a8c13c88485602c778e5d9564'/>
<id>786cf9db488dd83a8c13c88485602c778e5d9564</id>
<content type='text'>
Following [Feature #20589] it can happen that we change the
capacity of a frozen array, so these assertions no longer make
sense.

Normally we don't hit them because `Array#freeze` shrinks the
array, but if somehow the Array was frozen using `Object#freeze`
then we may shrink it after it was frozen.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Following [Feature #20589] it can happen that we change the
capacity of a frozen array, so these assertions no longer make
sense.

Normally we don't hit them because `Array#freeze` shrinks the
array, but if somehow the Array was frozen using `Object#freeze`
then we may shrink it after it was frozen.
</pre>
</div>
</content>
</entry>
<entry>
<title>Add regression test for mutating pack's format string</title>
<updated>2024-07-03T00:59:48+00:00</updated>
<author>
<name>Aaron Patterson</name>
<email>tenderlove@ruby-lang.org</email>
</author>
<published>2024-07-03T00:17:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=93b19d56de64fdee790a96ddf96fcd08d889ac93'/>
<id>93b19d56de64fdee790a96ddf96fcd08d889ac93</id>
<content type='text'>
It doesn't look like there was a test added for this bug, so I'm adding
it.

Code is from here:

  https://web.archive.org/web/20160908192307/http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-dev/24445
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It doesn't look like there was a test added for this bug, so I'm adding
it.

Code is from here:

  https://web.archive.org/web/20160908192307/http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-dev/24445
</pre>
</div>
</content>
</entry>
<entry>
<title>Resize ary when `Array#sort!` block modifies embedded ary</title>
<updated>2024-04-13T23:41:47+00:00</updated>
<author>
<name>Zack Deveau</name>
<email>zack.ref@gmail.com</email>
</author>
<published>2024-01-19T20:01:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c479492a6701dcef3d3a96de8946ecf7beb079d4'/>
<id>c479492a6701dcef3d3a96de8946ecf7beb079d4</id>
<content type='text'>
In cases where `rb_ary_sort_bang` is called with a block and
tmp is an embedded array, we need to account for the block
potentially impacting the capacity of ary.

ex:
```
var_0 = (1..70).to_a
var_0.sort! do |var_0_block_129, var_1_block_129|
  var_0.pop
  var_1_block_129 &lt;=&gt; var_0_block_129
end.shift(3)
```

The above example can put the array into a corrupted state
resulting in a heap buffer overflow and possible segfault:
```
ERROR: AddressSanitizer: heap-buffer-overflow on address [...]
WRITE of size 560 at 0x60b0000034f0 thread T0 [...]
```

This commit adds a conditional to determine when the capacity
of ary has been modified by the provided block. If this is
the case, ensure that the capacity of ary is adjusted to
handle at minimum the len of tmp.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In cases where `rb_ary_sort_bang` is called with a block and
tmp is an embedded array, we need to account for the block
potentially impacting the capacity of ary.

ex:
```
var_0 = (1..70).to_a
var_0.sort! do |var_0_block_129, var_1_block_129|
  var_0.pop
  var_1_block_129 &lt;=&gt; var_0_block_129
end.shift(3)
```

The above example can put the array into a corrupted state
resulting in a heap buffer overflow and possible segfault:
```
ERROR: AddressSanitizer: heap-buffer-overflow on address [...]
WRITE of size 560 at 0x60b0000034f0 thread T0 [...]
```

This commit adds a conditional to determine when the capacity
of ary has been modified by the provided block. If this is
the case, ensure that the capacity of ary is adjusted to
handle at minimum the len of tmp.
</pre>
</div>
</content>
</entry>
</feed>
