diff options
author | Charles Oliver Nutter <[email protected]> | 2023-10-20 21:00:18 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2023-10-21 02:00:18 +0000 |
commit | 0e62802c3bdc2167b1c8e5f9db014f1e421f2c62 (patch) | |
tree | e8d460659165f16b0e22581213519dcb15c1aca1 /test/ruby/test_io_buffer.rb | |
parent | 8a88172fd44defba0e73ebef41d33a44ac71941d (diff) |
Extract IO::Buffer.for string locking test (#8729)
String locking with locktmp is not really part of the public API,
and the test relies in a side effect of using it to protect the
buffer. On other implementations without locktmp this does not
fail. Separate into its own test so it can be excluded from public
API expectations.
Diffstat (limited to 'test/ruby/test_io_buffer.rb')
-rw-r--r-- | test/ruby/test_io_buffer.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/test/ruby/test_io_buffer.rb b/test/ruby/test_io_buffer.rb index d5ba3266c7..1b4a09dd20 100644 --- a/test/ruby/test_io_buffer.rb +++ b/test/ruby/test_io_buffer.rb @@ -102,11 +102,6 @@ class TestIOBuffer < Test::Unit::TestCase IO::Buffer.for(string) do |buffer| refute buffer.readonly? - # Cannot modify string as it's locked by the buffer: - assert_raise RuntimeError do - string[0] = "h" - end - buffer.set_value(:U8, 0, "h".ord) # Buffer releases it's ownership of the string: @@ -116,6 +111,16 @@ class TestIOBuffer < Test::Unit::TestCase end end + def test_string_mapped_buffer_locked + string = "Hello World" + IO::Buffer.for(string) do |buffer| + # Cannot modify string as it's locked by the buffer: + assert_raise RuntimeError do + string[0] = "h" + end + end + end + def test_non_string not_string = Object.new |