Skip to content

Commit

Permalink
improve history test's encoding setting
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWzr committed Oct 19, 2024
1 parent 3da04b9 commit 99cabd0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/irb/test_history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@
module TestIRB
class HistoryTest < TestCase
def setup
@conf_backup = IRB.conf.dup
@original_verbose, $VERBOSE = $VERBOSE, nil
@tmpdir = Dir.mktmpdir("test_irb_history_")
setup_envs(home: @tmpdir)
@backup_default_external = Encoding.default_external
save_encodings
IRB.instance_variable_set(:@existing_rc_name_generators, nil)
end

def teardown
IRB.conf.replace(@conf_backup)
IRB.instance_variable_set(:@existing_rc_name_generators, nil)
teardown_envs
Encoding.default_external = @backup_default_external
restore_encodings
$VERBOSE = @original_verbose
FileUtils.rm_rf(@tmpdir)
end
Expand Down Expand Up @@ -163,7 +165,7 @@ def test_history_concurrent_use_not_present

def test_history_different_encodings
IRB.conf[:SAVE_HISTORY] = 2
Encoding.default_external = Encoding::US_ASCII
IRB.__send__(:set_encoding, Encoding::US_ASCII.name)
locale = IRB::Locale.new("en_US.ASCII")
assert_history(<<~EXPECTED_HISTORY.encode(Encoding::US_ASCII), <<~INITIAL_HISTORY.encode(Encoding::UTF_8), <<~INPUT, locale: locale)
????
Expand Down

0 comments on commit 99cabd0

Please sign in to comment.