Skip to content

Commit

Permalink
- Cleaning up ancient code checking for defined?(Encoding) and the like.
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//src/minitest/dev/": change = 14271]
  • Loading branch information
zenspider committed Jul 31, 2024
1 parent 2bd62c5 commit 1156b6c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 33 deletions.
17 changes: 6 additions & 11 deletions lib/minitest/assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,15 @@ def things_to_diff exp, act
# See Minitest::Test.make_my_diffs_pretty!

def mu_pp obj
s = obj.inspect
s = obj.inspect.encode Encoding.default_external

if defined? Encoding then
s = s.encode Encoding.default_external
return s unless String === obj &&
(obj.encoding != Encoding.default_external || !obj.valid_encoding?)

if String === obj && (obj.encoding != Encoding.default_external ||
!obj.valid_encoding?) then
enc = "# encoding: #{obj.encoding}"
val = "# valid: #{obj.valid_encoding?}"
s = "#{enc}\n#{val}\n#{s}"
end
end
enc = "# encoding: #{obj.encoding}"
val = "# valid: #{obj.valid_encoding?}"

s
[enc, val, s].join "\n"
end

##
Expand Down
18 changes: 8 additions & 10 deletions test/minitest/test_minitest_assertions.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
require "minitest/autorun"
require_relative "metametameta"

if defined? Encoding then
e = Encoding.default_external
if e != Encoding::UTF_8 then
warn ""
warn ""
warn "NOTE: External encoding #{e} is not UTF-8. Tests WILL fail."
warn " Run tests with `RUBYOPT=-Eutf-8 rake` to avoid errors."
warn ""
warn ""
end
e = Encoding.default_external
if e != Encoding::UTF_8 then
warn ""
warn ""
warn "NOTE: External encoding #{e} is not UTF-8. Tests WILL fail."
warn " Run tests with `RUBYOPT=-Eutf-8 rake` to avoid errors."
warn ""
warn ""
end

SomeError = Class.new Exception
Expand Down
20 changes: 8 additions & 12 deletions test/minitest/test_minitest_test.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
require "minitest/metametameta"

if defined? Encoding then
e = Encoding.default_external
if e != Encoding::UTF_8 then
warn ""
warn ""
warn "NOTE: External encoding #{e} is not UTF-8. Tests WILL fail."
warn " Run tests with `RUBYOPT=-Eutf-8 rake` to avoid errors."
warn ""
warn ""
end
e = Encoding.default_external
if e != Encoding::UTF_8 then
warn ""
warn ""
warn "NOTE: External encoding #{e} is not UTF-8. Tests WILL fail."
warn " Run tests with `RUBYOPT=-Eutf-8 rake` to avoid errors."
warn ""
warn ""
end

class Minitest::Runnable
Expand Down Expand Up @@ -989,8 +987,6 @@ class TestMinitestUnitTestCase < Minitest::Test
# which is not threadsafe. Nearly every method in here is an
# assertion test so it isn't worth splitting it out further.

RUBY18 = !defined? Encoding

def setup
super

Expand Down

0 comments on commit 1156b6c

Please sign in to comment.