summaryrefslogtreecommitdiff
path: root/test/optparse/test_optparse.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/optparse/test_optparse.rb')
-rw-r--r--test/optparse/test_optparse.rb17
1 files changed, 14 insertions, 3 deletions
diff --git a/test/optparse/test_optparse.rb b/test/optparse/test_optparse.rb
index 7f35cb4a8a..ff334009a6 100644
--- a/test/optparse/test_optparse.rb
+++ b/test/optparse/test_optparse.rb
@@ -184,10 +184,9 @@ class TestOptionParser < Test::Unit::TestCase
File.open(File.join(dir, "options.rb"), "w") do |f|
f.puts "#{<<~"begin;"}\n#{<<~'end;'}"
begin;
- stdout = STDOUT.dup
+ stdout = $stdout.dup
def stdout.tty?; true; end
- Object.__send__(:remove_const, :STDOUT)
- STDOUT = stdout
+ $stdout = stdout
ARGV.options do |opt|
end;
100.times {|i| f.puts " opt.on('--opt-#{i}') {}"}
@@ -217,4 +216,16 @@ class TestOptionParser < Test::Unit::TestCase
end
end
end
+
+ def test_program_name
+ program = $0
+ $0 = "rdbg3.5"
+ assert_equal "rdbg3.5", OptionParser.new.program_name
+ RbConfig::CONFIG["EXECUTABLE_EXTS"]&.split(" ") do |ext|
+ $0 = "rdbg3.5" + ext
+ assert_equal "rdbg3.5", OptionParser.new.program_name
+ end
+ ensure
+ $0 = program
+ end
end