summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBenoit Daloze <[email protected]>2025-06-14 13:49:28 +0200
committerBenoit Daloze <[email protected]>2025-06-16 22:59:10 +0200
commit2956573b09ec78d7735a07fe3d7b2dcc907879fb (patch)
treeafeebe7385b3dcc442ba045ebed8d30679b0da25 /test
parent83fb07fb2c97b9922450979fa4a56f43324317a9 (diff)
Add test for `IO::Buffer.for(frozen_string) {}` and omit rb_str_{,un}locktmp in that case
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13615
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_io_buffer.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_io_buffer.rb b/test/ruby/test_io_buffer.rb
index 55296c1f23..70c5ef061d 100644
--- a/test/ruby/test_io_buffer.rb
+++ b/test/ruby/test_io_buffer.rb
@@ -121,6 +121,16 @@ class TestIOBuffer < Test::Unit::TestCase
end
end
+ def test_string_mapped_buffer_frozen
+ string = "Hello World".freeze
+ IO::Buffer.for(string) do |buffer|
+ assert_raise IO::Buffer::AccessError, "Buffer is not writable!" do
+ buffer.set_string("abc")
+ end
+ assert_equal "H".ord, buffer.get_value(:U8, 0)
+ end
+ end
+
def test_non_string
not_string = Object.new