about summary refs log tree commit homepage
path: root/test/test_posix_mq.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-03-13 00:22:22 -0800
committerEric Wong <normalperson@yhbt.net>2010-03-13 00:22:22 -0800
commit437cbe78cb0f239e34f9dbf1341f5b85f96f2f25 (patch)
treef8f244f5e71fb315d971da021b881567d5f5c425 /test/test_posix_mq.rb
parent74e1f75b238416d9ac402f291431a5e457ae313f (diff)
downloadruby_posix_mq-437cbe78cb0f239e34f9dbf1341f5b85f96f2f25.tar.gz
We don't want folks to accidentally clobber the value for
others, so allocate a new string object for it (don't worry,
rb_str_dup() is cheap in 1.9).
Diffstat (limited to 'test/test_posix_mq.rb')
-rw-r--r--test/test_posix_mq.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/test_posix_mq.rb b/test/test_posix_mq.rb
index fa98a9c..963d623 100644
--- a/test/test_posix_mq.rb
+++ b/test/test_posix_mq.rb
@@ -27,6 +27,15 @@ class Test_POSIX_MQ < Test::Unit::TestCase
     assert @mq.closed?
   end
 
+  def test_name_clobber_proof
+    @mq = POSIX_MQ.new(@path, :rw)
+    tmp = @mq.name
+    tmp.freeze
+    assert_nothing_raised { @mq.name.gsub!(/\A/, "foo") }
+    assert_equal tmp, @mq.name
+    assert tmp.object_id != @mq.name.object_id
+  end
+
   def test_dup_clone
     @mq = POSIX_MQ.new(@path, :rw)
     dup = @mq.dup