From 7590de68e2102d586a1fb4e34642643b3c731269 Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 11 Mar 2013 08:29:46 +0000 Subject: * test/ruby/envutil.rb (EnvUtil.with_default_external): add for changing Encoding.default_external without warnings. * test/ruby/envutil.rb (EnvUtil.with_default_internal): ditto. * test/ruby/test_io_m17n.rb: use above with_default_external. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/envutil.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/ruby/envutil.rb') diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb index a8f3874e9f..98b89edd8c 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -127,6 +127,30 @@ module EnvUtil GC.stress = stress end module_function :under_gc_stress + + def with_default_external(enc) + verbose, $VERBOSE = $VERBOSE, nil + origenc, Encoding.default_external = Encoding.default_external, enc + $VERBOSE = verbose + yield + ensure + verbose, $VERBOSE = $VERBOSE, nil + Encoding.default_external = origenc + $VERBOSE = verbose + end + module_function :with_default_external + + def with_default_internal(enc) + verbose, $VERBOSE = $VERBOSE, nil + origenc, Encoding.default_internal = Encoding.default_internal, enc + $VERBOSE = verbose + yield + ensure + verbose, $VERBOSE = $VERBOSE, nil + Encoding.default_internal = origenc + $VERBOSE = verbose + end + module_function :with_default_internal end module Test -- cgit v1.2.3