diff options
author | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-10-05 02:56:42 +0000 |
---|---|---|
committer | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-10-05 02:56:42 +0000 |
commit | d77b17aa73110c289c354316bb9c600f53bb3684 (patch) | |
tree | 8dc570bcfc105400f00ab658ef166085e0ef7575 /test | |
parent | 1e85ca8a02a4e0e77f2144e91bf12d920993a303 (diff) | |
download | ruby-d77b17aa73110c289c354316bb9c600f53bb3684.tar.gz |
* test/ruby/envutil.rb: added. split "rubybin" from test_system.rb.
* test/ruby/test_system.rb: use envutil.rb
* test/ruby/test_beginendblock.rb: added.
* test/ruby/beginmainend.rb: added. used in test_beginendblock.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/beginmainend.rb | 9 | ||||
-rw-r--r-- | test/ruby/envutil.rb | 10 | ||||
-rw-r--r-- | test/ruby/test_beginendblock.rb | 12 | ||||
-rw-r--r-- | test/ruby/test_system.rb | 7 |
4 files changed, 33 insertions, 5 deletions
diff --git a/test/ruby/beginmainend.rb b/test/ruby/beginmainend.rb new file mode 100644 index 0000000000..4ee1d7899a --- /dev/null +++ b/test/ruby/beginmainend.rb @@ -0,0 +1,9 @@ +BEGIN { + puts "begin" +} + +puts "main" + +END { + puts "end" +} diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb new file mode 100644 index 0000000000..3f0fed3ad5 --- /dev/null +++ b/test/ruby/envutil.rb @@ -0,0 +1,10 @@ +module EnvUtil + def rubybin + if File.exist? "miniruby" or File.exist? "miniruby.exe" + "./miniruby" + else + "ruby" + end + end + module_function :rubybin +end diff --git a/test/ruby/test_beginendblock.rb b/test/ruby/test_beginendblock.rb new file mode 100644 index 0000000000..301d2c62f5 --- /dev/null +++ b/test/ruby/test_beginendblock.rb @@ -0,0 +1,12 @@ +require 'test/unit' +require "#{File.dirname(File.expand_path(__FILE__))}/envutil" + +class TestBeginEndBlock < Test::Unit::TestCase + DIR = File.dirname(File.expand_path(__FILE__)) + + def test_beginendblock + ruby = EnvUtil.rubybin + io = IO.popen("\"#{ruby}\" \"#{DIR}/beginmainend.rb\"") + assert_equal("begin\nmain\nend\n", io.read) + end +end diff --git a/test/ruby/test_system.rb b/test/ruby/test_system.rb index a3da43459f..da4deb5a04 100644 --- a/test/ruby/test_system.rb +++ b/test/ruby/test_system.rb @@ -1,4 +1,5 @@ require 'test/unit' +require "#{File.dirname(File.expand_path(__FILE__))}/envutil" $KCODE = 'none' @@ -8,11 +9,7 @@ class TestSystem < Test::Unit::TestCase end def test_system - if File.exist? "miniruby" or File.exist? "miniruby.exe" - ruby = "./miniruby" - else - ruby = "ruby" - end + ruby = EnvUtil.rubybin assert_equal("foobar\n", `echo foobar`) assert_equal('foobar', `#{ruby} -e 'print "foobar"'`) |