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.
This commit is contained in:
Charles Oliver Nutter 2023-10-20 21:00:18 -05:00 коммит произвёл GitHub
Родитель 8a88172fd4
Коммит 0e62802c3b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 10 добавлений и 5 удалений

Просмотреть файл

@ -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