From 7f199d12e0ee9a095d186a8667f78f31fa0a2dca Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 12 Mar 2012 15:17:27 +0000 Subject: Add missing assert_warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_io_m17n.rb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'test/ruby/test_io_m17n.rb') diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index eccc27ac97..b86dfb3274 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -1,6 +1,7 @@ require 'test/unit' require 'tmpdir' require 'timeout' +require 'stringio' require_relative 'envutil' class TestIO_M17N < Test::Unit::TestCase @@ -11,6 +12,17 @@ class TestIO_M17N < Test::Unit::TestCase Encoding::UTF_8 ] + def assert_warning(pat, mesg=nil) + begin + org_stderr = $stderr + $stderr = StringIO.new(warn = '') + yield + ensure + $stderr = org_stderr + end + assert_match(pat, warn, mesg) + end + def with_tmpdir Dir.mktmpdir {|dir| Dir.chdir(dir) { @@ -1064,9 +1076,9 @@ EOT bug5567 = '[ruby-core:40726]' IO.pipe do |r, w| assert_nothing_raised(bug5567) do - assert_warn(/Unsupported/, bug5567) {r.set_encoding("fffffffffffxx")} - assert_warn(/Unsupported/, bug5567) {r.set_encoding("fffffffffffxx", "us-ascii")} - assert_warn(/Unsupported/, bug5567) {r.set_encoding("us-ascii", "fffffffffffxx")} + assert_warning(/Unsupported/, bug5567) {r.set_encoding("fffffffffffxx")} + assert_warning(/Unsupported/, bug5567) {r.set_encoding("fffffffffffxx", "us-ascii")} + assert_warning(/Unsupported/, bug5567) {r.set_encoding("us-ascii", "fffffffffffxx")} end end end -- cgit v1.2.3