1require 'test/unit' 2require 'tmpdir' 3 4class TestNotImplement < Test::Unit::TestCase 5 def test_respond_to_fork 6 assert_include(Process.methods, :fork) 7 if /linux/ =~ RUBY_PLATFORM 8 assert_equal(true, Process.respond_to?(:fork)) 9 end 10 end 11 12 def test_respond_to_lchmod 13 assert_include(File.methods, :lchmod) 14 if /linux/ =~ RUBY_PLATFORM 15 assert_equal(false, File.respond_to?(:lchmod)) 16 end 17 if /freebsd/ =~ RUBY_PLATFORM 18 assert_equal(true, File.respond_to?(:lchmod)) 19 end 20 end 21 22 def test_call_fork 23 if Process.respond_to?(:fork) 24 assert_nothing_raised { 25 pid = fork {} 26 Process.wait pid 27 } 28 end 29 end 30 31 def test_call_lchmod 32 if File.respond_to?(:lchmod) 33 Dir.mktmpdir {|d| 34 f = "#{d}/f" 35 g = "#{d}/g" 36 File.open(f, "w") {} 37 File.symlink f, g 38 newmode = 0444 39 File.lchmod newmode, "#{d}/g" 40 snew = File.lstat(g) 41 assert_equal(newmode, snew.mode & 0777) 42 } 43 end 44 end 45 46 def test_method_inspect_fork 47 m = Process.method(:fork) 48 if Process.respond_to?(:fork) 49 assert_not_match(/not-implemented/, m.inspect) 50 else 51 assert_match(/not-implemented/, m.inspect) 52 end 53 end 54 55 def test_method_inspect_lchmod 56 m = File.method(:lchmod) 57 if File.respond_to?(:lchmod) 58 assert_not_match(/not-implemented/, m.inspect) 59 else 60 assert_match(/not-implemented/, m.inspect) 61 end 62 end 63 64end 65