From 57d414a1c7f59b0e15490bc709d6dd361ef99deb Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 7 Mar 2010 06:54:29 +0000 Subject: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_rubyoptions.rb | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'test/ruby/test_rubyoptions.rb') diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index ee5331c18e..4c49d31d93 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -325,6 +325,45 @@ class TestRubyOptions < Test::Unit::TestCase assert_in_out_err([notexist], "", [], pat) end + def test_program_name + ruby = EnvUtil.rubybin + IO.popen([ruby, '-e', 'print $0']) {|f| + assert_equal('-e', f.read) + } + IO.popen([ruby, '-'], 'r+') {|f| + f << 'print $0' + f.close_write + assert_equal('-', f.read) + } + Dir.mktmpdir {|d| + n1 = File.join(d, 't1') + open(n1, 'w') {|f| f << 'print $0' } + IO.popen([ruby, n1]) {|f| + assert_equal(n1, f.read) + } + if File.respond_to? :symlink + n2 = File.join(d, 't2') + File.symlink(n1, n2) + IO.popen([ruby, n2]) {|f| + assert_equal(n2, f.read) + } + end + Dir.chdir(d) { + n3 = '-e' + open(n3, 'w') {|f| f << 'print $0' } + IO.popen([ruby, '--', n3]) {|f| + assert_equal(n3, f.read) + } + n4 = '-' + IO.popen([ruby, '--', n4], 'r+') {|f| + f << 'print $0' + f.close_write + assert_equal(n4, f.read) + } + } + } + end + def test_segv_test assert_in_out_err(["-e", "Process.kill :SEGV, $$"], "", [], %r(\A -- cgit v1.2.3