summaryrefslogtreecommitdiff
path: root/test/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-09 01:25:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-09 01:25:11 +0000
commit404bf57aaffd64cb251574e2916e393d272f77a3 (patch)
tree7d8a4973cb71de85d1917b1bf17c5cd6f625393d /test/lib
parent56417d1f24ab6f505f431de067d3cfa596600c65 (diff)
assertions.rb: set default internal encoding
* test/lib/test/unit/assertions.rb (assert_raise_with_message): set default internal encoding to the excpected message, which affects String#inspect in messages. * test/lib/test/unit/assertions.rb (assert_warning): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/lib')
-rw-r--r--test/lib/test/unit/assertions.rb20
1 files changed, 15 insertions, 5 deletions
diff --git a/test/lib/test/unit/assertions.rb b/test/lib/test/unit/assertions.rb
index 3cbf32882e..e2bea19c00 100644
--- a/test/lib/test/unit/assertions.rb
+++ b/test/lib/test/unit/assertions.rb
@@ -131,14 +131,20 @@ module Test
raise TypeError, "Expected #{expected.inspect} to be a kind of String or Regexp, not #{expected.class}"
end
- ex = assert_raise(exception, msg || proc {"Exception(#{exception}) with message matches to #{expected.inspect}"}) {yield}
+ ex = m = nil
+ EnvUtil.with_default_internal(expected.encoding) do
+ ex = assert_raise(exception, msg || proc {"Exception(#{exception}) with message matches to #{expected.inspect}"}) do
+ yield
+ end
+ m = ex.message
+ end
msg = message(msg, "") {"Expected Exception(#{exception}) was raised, but the message doesn't match"}
if assert == :assert_equal
- assert_equal(expected, ex.message, msg)
+ assert_equal(expected, m, msg)
else
- msg = message(msg) { "Expected #{mu_pp expected} to match #{mu_pp ex.message}" }
- assert expected =~ ex.message, msg
+ msg = message(msg) { "Expected #{mu_pp expected} to match #{mu_pp m}" }
+ assert expected =~ m, msg
block.binding.eval("proc{|_|$~=_}").call($~)
end
ex
@@ -626,7 +632,11 @@ eom
end
def assert_warning(pat, msg = nil)
- stderr = EnvUtil.verbose_warning { yield }
+ stderr = EnvUtil.verbose_warning {
+ EnvUtil.with_default_internal(pat.encoding) {
+ yield
+ }
+ }
msg = message(msg) {diff pat, stderr}
assert(pat === stderr, msg)
end