diff options
author | Jean Boussier <[email protected]> | 2024-04-16 14:52:58 +0200 |
---|---|---|
committer | git <[email protected]> | 2024-05-05 08:00:00 +0000 |
commit | 7d42010fad4be2dbb26bd7608a75aa1c51d5f9ef (patch) | |
tree | 9be9332fe99a42a88bc8fc00e2a0f5b8ce139f1a /test/openssl | |
parent | fca6c55a535094a49cf16d00519120d57928b1a2 (diff) |
[ruby/openssl] read: don't clear buffer when nothing can be read
To be consistent with regular Ruby IOs:
```ruby
r, _ = IO.pipe
buf = "garbage".b
r.read_nonblock(10, buf, exception: false) # => :wait_readable
p buf # => "garbage"
```
Ref: https://github.com/redis-rb/redis-client/commit/98b8944460a11f8508217bda71cfc10cb2190d4d
https://github.com/ruby/openssl/commit/08452993d6
Diffstat (limited to 'test/openssl')
-rw-r--r-- | test/openssl/test_pair.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/test/openssl/test_pair.rb b/test/openssl/test_pair.rb index b616883925..66e36a7ab4 100644 --- a/test/openssl/test_pair.rb +++ b/test/openssl/test_pair.rb @@ -250,12 +250,17 @@ module OpenSSL::TestPairM buf = +"garbage" assert_equal :wait_readable, s2.read_nonblock(100, buf, exception: false) - assert_equal "", buf + assert_equal "garbage", buf s1.close buf = +"garbage" - assert_equal nil, s2.read(100, buf) + assert_nil s2.read(100, buf) assert_equal "", buf + + buf = +"garbage" + ret = s2.read(0, buf) + assert_same buf, ret + assert_equal "", ret } end |