diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-04-10 22:33:58 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-04-10 22:33:58 +0000 |
commit | 6ba4bd5858753c1aff9d11cfa7c478b9616c109a (patch) | |
tree | 4fea4bdc94488c12c11a02d8e3a79c5804d6724f /test/ruby | |
parent | 38ce9797c1b0b5b89cbff9bde72a50fa55f4f335 (diff) | |
download | ruby-6ba4bd5858753c1aff9d11cfa7c478b9616c109a.tar.gz |
* pack.c (pack_pack): Warn when an invalid character is found in the
format string when $VERBOSE is true. [ruby-trunk - Feature #5219]
* pack.c (pack_unpack): ditto
* test/ruby/test_pack.rb (class TestPack): Test for warnings on
invalid format characters.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_pack.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb index c862215cb4..e623a69cbf 100644 --- a/test/ruby/test_pack.rb +++ b/test/ruby/test_pack.rb @@ -651,4 +651,39 @@ class TestPack < Test::Unit::TestCase assert_nil("".unpack("i") {|x| result = x}, bug4059) assert_equal(:ok, result) end + + def test_pack_garbage + assert_silent do + assert_equal "\000", [0].pack("*U") + end + + verbose = $VERBOSE + $VERBOSE = true + + _, err = capture_io do + assert_equal "\000", [0].pack("*U") + end + + assert_match %r%unknown pack directive '\*' in '\*U'$%, err + ensure + $VERBOSE = verbose + end + + def test_unpack_garbage + assert_silent do + assert_equal [0], "\000".unpack("*U") + end + + verbose = $VERBOSE + $VERBOSE = true + + _, err = capture_io do + assert_equal [0], "\000".unpack("*U") + end + + assert_match %r%unknown unpack directive '\*' in '\*U'$%, err + ensure + $VERBOSE = verbose + end + end |