summaryrefslogtreecommitdiff
path: root/tool/lib
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2025-03-13 12:51:04 +0900
committerNobuyoshi Nakada <[email protected]>2025-03-17 23:42:16 +0900
commit4c072c811905610a84107fdae103982d144b3d71 ()
tree8a1dc4253cc88975603c8f01477b6393f65b45b9 /tool/lib
parent8f19f0aad5f87d481b5ae4337afdb844bcce1885 (diff)
Fix `assert_warning` for `Proc`
`Proc` does not have `encoding` method. Also, make `assert_raise_with_message` accept a `Proc` as the expected pattern, as well.
Notes: Merged: https://.com/ruby/ruby/pull/12923
-rw-r--r--tool/lib/core_assertions.rb9
-rw-r--r--tool/lib/envutil.rb6
2 files changed, 8 insertions, 7 deletions
@@ -489,14 +489,13 @@ eom
case expected
when String
assert = :assert_equal
- when Regexp
- assert = :assert_match
else
- raise TypeError, "Expected #{expected.inspect} to be a kind of String or Regexp, not #{expected.class}"
end
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
@@ -670,7 +669,7 @@ eom
def assert_warning(pat, msg = nil)
result = nil
- stderr = EnvUtil.with_default_internal(pat.encoding) {
EnvUtil.verbose_warning {
result = yield
}
@@ -279,7 +279,8 @@ module EnvUtil
end
module_function :without_gc
- def with_default_external(enc)
suppress_warning { Encoding.default_external = enc }
yield
ensure
@@ -287,7 +288,8 @@ module EnvUtil
end
module_function :with_default_external
- def with_default_internal(enc)
suppress_warning { Encoding.default_internal = enc }
yield
ensure