Skip to content

Commit

Permalink
test_null_io.rb - fix up for Ruby 2.4, TruffleRuby (#3279)
Browse files Browse the repository at this point in the history
See #3276
  • Loading branch information
MSP-Greg authored and nateberkopec committed Jan 2, 2024
1 parent 899ebc5 commit fd07179
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/test_null_io.rb
Expand Up @@ -51,7 +51,8 @@ def test_read_with_negative_length
error = assert_raises ArgumentError do
nio.read(-42)
end
assert_includes error.message, "negative length -42 given"
# 2nd match is TruffleRuby
assert_match(/negative length -42 given|length must not be negative/, error.message)
end

def test_read_with_nil_buffer
Expand Down Expand Up @@ -87,15 +88,18 @@ def test_read_with_invalid_buffer
end

def test_read_with_frozen_buffer
assert_raises FrozenError do
# Remove when Ruby 2.4 is no longer supported
err = defined? ::FrozenError ? ::FrozenError : ::RuntimeError

assert_raises err do
nio.read(nil, "".freeze)
end

assert_raises FrozenError do
assert_raises err do
nio.read(0, "".freeze)
end

assert_raises FrozenError do
assert_raises err do
nio.read(20, "".freeze)
end
end
Expand Down

0 comments on commit fd07179

Please sign in to comment.