diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-03-07 08:39:39 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-03-07 08:39:39 +0000 |
commit | eb807d42eca121df22f72b95465bba52a4e7fefa (patch) | |
tree | 35b722bc6c94d3b9c5f8f80d41e889c591a80450 /test/ruby | |
parent | c414d861c109ff546e2bc8c7264859907d6e0f76 (diff) | |
download | ruby-eb807d42eca121df22f72b95465bba52a4e7fefa.tar.gz |
* gc.c (rb_gc_set_params): allow GC parameter configuration by
environment variables. based on a patch from funny-falcon at
https://gist.github.com/856296, but honors safe level.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_io.rb | 33 | ||||
-rw-r--r-- | test/ruby/test_m17n.rb | 1 | ||||
-rw-r--r-- | test/ruby/test_process.rb | 18 | ||||
-rw-r--r-- | test/ruby/test_string.rb | 32 | ||||
-rw-r--r-- | test/ruby/test_system.rb | 30 |
5 files changed, 24 insertions, 90 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 6b8e6b58ce..6cc2897f5f 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1776,37 +1776,4 @@ End end end end - - def test_fcntl_lock - return if /x86_64-linux/ !~ RUBY_PLATFORM # A binary form of struct flock depend on platform - - pad=0 - Tempfile.open(self.class.name) do |f| - r, w = IO.pipe - pid = fork do - r.close - lock = [Fcntl::F_WRLCK, IO::SEEK_SET, pad, 12, 34, 0].pack("s!s!i!L!L!i!") - f.fcntl Fcntl::F_SETLKW, lock - w.syswrite "." - sleep - end - w.close - assert_equal ".", r.read(1) - r.close - pad = 0 - getlock = [Fcntl::F_WRLCK, 0, pad, 0, 0, 0].pack("s!s!i!L!L!i!") - f.fcntl Fcntl::F_GETLK, getlock - - ptype, whence, pad, start, len, lockpid = getlock.unpack("s!s!i!L!L!i!") - - assert_equal(ptype, Fcntl::F_WRLCK) - assert_equal(whence, IO::SEEK_SET) - assert_equal(start, 12) - assert_equal(len, 34) - assert_equal(pid, lockpid) - - Process.kill :TERM, pid - Process.waitpid2(pid) - end - end end diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index c4bc9e6637..a29d509fc4 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -962,7 +962,6 @@ class TestM17N < Test::Unit::TestCase assert_equal("X\u3042\u3044X", "A\u3042\u3044\u3046".tr("^\u3042\u3044", "X")) assert_equal("\u3042\u3046" * 100, ("\u3042\u3044" * 100).tr("\u3044", "\u3046")) - assert_equal("Y", "\u3042".tr("^X", "Y")) end def test_tr_s diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index f3f3f9eb80..b45bfb9bb0 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -384,20 +384,16 @@ class TestProcess < Test::Unit::TestCase Process.wait Process.spawn(*ECHO["c"], STDERR=>STDOUT, STDOUT=>["out", File::WRONLY|File::CREAT|File::TRUNC, 0644]) assert_equal("c", File.read("out").chomp) File.open("out", "w") {|f| - Process.wait Process.spawn(*ECHO["d"], STDOUT=>f) + Process.wait Process.spawn(*ECHO["d"], f=>STDOUT, STDOUT=>f) assert_equal("d", File.read("out").chomp) } - opts = {STDOUT=>["out", File::WRONLY|File::CREAT|File::TRUNC, 0644]} - if /mswin|mingw/ !~ RUBY_PLATFORM - opts.merge(3=>STDOUT, 4=>STDOUT, 5=>STDOUT, 6=>STDOUT, 7=>STDOUT) - end - Process.wait Process.spawn(*ECHO["e"], opts) + Process.wait Process.spawn(*ECHO["e"], STDOUT=>["out", File::WRONLY|File::CREAT|File::TRUNC, 0644], + 3=>STDOUT, 4=>STDOUT, 5=>STDOUT, 6=>STDOUT, 7=>STDOUT) assert_equal("e", File.read("out").chomp) - opts = {STDOUT=>["out", File::WRONLY|File::CREAT|File::TRUNC, 0644]} - if /mswin|mingw/ !~ RUBY_PLATFORM - opts.merge(3=>0, 4=>:in, 5=>STDIN, 6=>1, 7=>:out, 8=>STDOUT, 9=>2, 10=>:err, 11=>STDERR) - end - Process.wait Process.spawn(*ECHO["ee"], opts) + Process.wait Process.spawn(*ECHO["ee"], STDOUT=>["out", File::WRONLY|File::CREAT|File::TRUNC, 0644], + 3=>0, 4=>:in, 5=>STDIN, + 6=>1, 7=>:out, 8=>STDOUT, + 9=>2, 10=>:err, 11=>STDERR) assert_equal("ee", File.read("out").chomp) if /mswin|mingw/ !~ RUBY_PLATFORM # passing non-stdio fds is not supported on Windows diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index faa7bd670d..c5d3a53850 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1944,36 +1944,4 @@ class TestString < Test::Unit::TestCase assert_equal(S("hello world"), a) assert_equal(S("hello "), b) end - - def u(str) - str.force_encoding(Encoding::UTF_8) - end - - def test_byteslice - assert_equal("h", "hello".byteslice(0)) - assert_equal(nil, "hello".byteslice(5)) - assert_equal("o", "hello".byteslice(-1)) - assert_equal(nil, "hello".byteslice(-6)) - - assert_equal("", "hello".byteslice(0, 0)) - assert_equal("hello", "hello".byteslice(0, 6)) - assert_equal("hello", "hello".byteslice(0, 6)) - assert_equal("", "hello".byteslice(5, 1)) - assert_equal("o", "hello".byteslice(-1, 6)) - assert_equal(nil, "hello".byteslice(-6, 1)) - assert_equal(nil, "hello".byteslice(0, -1)) - - assert_equal("h", "hello".byteslice(0..0)) - assert_equal("", "hello".byteslice(5..0)) - assert_equal("o", "hello".byteslice(4..5)) - assert_equal(nil, "hello".byteslice(6..0)) - assert_equal("", "hello".byteslice(-1..0)) - assert_equal("llo", "hello".byteslice(-3..5)) - - assert_equal(u("\x81"), "\u3042".byteslice(1)) - assert_equal(u("\x81\x82"), "\u3042".byteslice(1, 2)) - assert_equal(u("\x81\x82"), "\u3042".byteslice(1..2)) - - assert_equal(u("\x82")+("\u3042"*9), ("\u3042"*10).byteslice(2, 28)) - end end diff --git a/test/ruby/test_system.rb b/test/ruby/test_system.rb index f1372781cf..bb77ad445e 100644 --- a/test/ruby/test_system.rb +++ b/test/ruby/test_system.rb @@ -91,13 +91,24 @@ class TestSystem < Test::Unit::TestCase def test_system_at if /mswin|mingw/ =~ RUBY_PLATFORM bug4393 = '[ruby-core:35218]' + bug4396 = '[ruby-core:35227]' # @ + builtin command assert_equal("foo\n", `@echo foo`, bug4393); assert_equal("foo\n", `@@echo foo`, bug4393); assert_equal("@@foo\n", `@@echo @@foo`, bug4393); - # @ + non builtin command + # "" + @ + built-in + assert_equal("@@foo\n", `"echo" @@foo`, bug4396); + assert_equal("@@foo\n", `"@@echo" @@foo`, bug4396); + assert_equal("@@foo\n", `"@@echo @@foo"`, bug4396); + assert_equal('"@foo"\n', `"echo" "@foo"`, bug4396); + + # ^ + @ + built-in + assert_equal(nil, system('^@echo foo'), bug4396); + assert_equal(nil, system('"^@echo foo"'), bug4396); + assert_equal("@foo\n", `echo ^@foo`); + Dir.mktmpdir("ruby_script_tmp") {|tmpdir| tmpfilename = "#{tmpdir}/ruby_script_tmp.#{$$}" @@ -105,23 +116,16 @@ class TestSystem < Test::Unit::TestCase tmp.print "foo\nbar\nbaz\n@foo"; tmp.close + # @ + non builtin command assert_match(/\Abar\nbaz\n?\z/, `@@findstr "ba" #{tmpfilename.gsub("/", "\\")}`, bug4393); + + # "" + @ + non built-in + assert_match(/\Abar\nbaz\n?\z/, `"@@findstr" "ba" #{tmpfilename.gsub("/", "\\")}`, bug4396); + assert_match(/\A@foo\n?\z/, `"@@findstr" "@foo" #{tmpfilename.gsub("/", "\\")}`, bug4396); } end end - def test_system_redirect_win - if /mswin|mingw/ !~ RUBY_PLATFORM - return - end - - cmd = "%WINDIR%/system32/ping.exe \"BFI3CHL671\" > out.txt 2>NUL" - assert_equal(false, system(cmd), '[ruby-talk:258939]'); - - cmd = "\"%WINDIR%/system32/ping.exe BFI3CHL671\" > out.txt 2>NUL" - assert_equal(false, system(cmd), '[ruby-talk:258939]'); - end - def test_empty_evstr assert_equal("", eval('"#{}"', nil, __FILE__, __LINE__), "[ruby-dev:25113]") end |