summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2021-10-22 15:04:22 +1300
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2021-11-12 16:46:08 +1300
commit98b442e013afbb450f1c946d86ed625c39ab3233 (patch)
tree6cce5e1b6e641e7d5160897ba0842c013a6737de /test/ruby
parente73197dff54cbe00019bec7a1829fdc6b1821918 (diff)
More immutability and locking tests.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5109
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_io_buffer.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/ruby/test_io_buffer.rb b/test/ruby/test_io_buffer.rb
index ec10d2e1e6..1bd839e163 100644
--- a/test/ruby/test_io_buffer.rb
+++ b/test/ruby/test_io_buffer.rb
@@ -44,6 +44,19 @@ class TestIOBuffer < Test::Unit::TestCase
assert buffer.mapped?
end
+ def test_new_immutable
+ buffer = IO::Buffer.new(128, IO::Buffer::INTERNAL|IO::Buffer::IMMUTABLE)
+ assert buffer.immutable?
+
+ assert_raise RuntimeError do
+ buffer.copy("", 0)
+ end
+
+ assert_raise RuntimeError do
+ buffer.copy("!", 1)
+ end
+ end
+
def test_file_mapped
buffer = File.open(__FILE__) {|file| IO::Buffer.map(file)}
assert_include buffer.to_str, "Hello World"
@@ -103,6 +116,22 @@ class TestIOBuffer < Test::Unit::TestCase
# end
end
+ def test_locked
+ buffer = IO::Buffer.new(128, IO::Buffer::INTERNAL|IO::Buffer::LOCKED)
+
+ assert_raise RuntimeError do
+ buffer.resize(256, 0)
+ end
+
+ assert_equal 128, buffer.size
+
+ assert_raise RuntimeError do
+ buffer.free
+ end
+
+ assert_equal 128, buffer.size
+ end
+
def test_invalidation
input, output = IO.pipe