summaryrefslogtreecommitdiff
path: root/test/ruby/test_pack.rb
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-15 14:37:18 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-15 14:37:18 +0000
commitb8118e9645ca5e656975b6dae9ac88219fecee23 (patch)
tree7d2d9d454ecb67d5acd5b36f7a344891af96777b /test/ruby/test_pack.rb
parent41bf214fd7273b2156e96dd600d57a578481daf1 (diff)
* test/ruby/test_string.rb: add tests to achieve over 90% test
coverage of string.c. * test/ruby/test_m17n.rb: ditto. * test/ruby/test_symbol.rb: ditto. * test/ruby/test_pack.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_pack.rb')
-rw-r--r--test/ruby/test_pack.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb
index 85d0b7cdfa8..b388937578e 100644
--- a/test/ruby/test_pack.rb
+++ b/test/ruby/test_pack.rb
@@ -63,6 +63,7 @@ class TestPack < Test::Unit::TestCase
assert_equal a, a.pack("P").unpack("P*")
assert_equal "a", a.pack("P").unpack("P")[0]
assert_equal a, a.pack("P").freeze.unpack("P*")
+ assert_raise(ArgumentError) { (a.pack("P") + "").unpack("P*") }
end
def test_pack_p
@@ -70,6 +71,7 @@ class TestPack < Test::Unit::TestCase
assert_equal a, a.pack("p").unpack("p*")
assert_equal a[0], a.pack("p").unpack("p")[0]
assert_equal a, a.pack("p").freeze.unpack("p*")
+ assert_raise(ArgumentError) { (a.pack("p") + "").unpack("p*") }
end
def test_format_string_modified
@@ -429,4 +431,14 @@ class TestPack < Test::Unit::TestCase
assert_equal([0xffffffff], "\217\377\377\377\177".unpack("w"), [0xffffffff])
assert_equal([0x100000000], "\220\200\200\200\000".unpack("w"), [0x100000000])
end
+
+ def test_modify_under_safe4
+ s = "foo"
+ assert_raise(SecurityError) do
+ Thread.new do
+ $SAFE = 4
+ s.clear
+ end.join
+ end
+ end
end