summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_pack.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb
index a0c66c188b..ca089f09c3 100644
--- a/test/ruby/test_pack.rb
+++ b/test/ruby/test_pack.rb
@@ -913,4 +913,27 @@ EXPECTED
assert_equal "oh no", v
end;
end
+
+ def test_monkey_pack_buffer
+ assert_separately([], <<-'end;')
+ $-w = false
+ class Array
+ alias :old_pack :pack
+ def pack _, buffer:; buffer << " no"; end
+ end
+
+ def test
+ b = +"oh"
+ [2 ** 15].pack('n', buffer: b)
+ end
+
+ v = test
+
+ class Array
+ alias :pack :old_pack
+ end
+
+ assert_equal "oh no", v
+ end;
+ end
end