1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

add tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2009-12-15 17:21:09 +00:00
parent 79933d6669
commit 6aafca91db

View file

@ -148,6 +148,52 @@ class TestFind < Test::Unit::TestCase
}
end
def test_change_dir_to_file
Dir.mktmpdir {|d|
Dir.mkdir(dir_1 = "#{d}/d1")
File.open(file_a = "#{dir_1}/a", "w"){}
File.open(file_b = "#{dir_1}/b", "w"){}
File.open(file_c = "#{dir_1}/c", "w"){}
Dir.mkdir(dir_d = "#{dir_1}/d")
File.open(file_de = "#{dir_d}/e", "w"){}
dir_2 = "#{d}/d2"
a = []
Find.find(d) {|f|
a << f
if f == file_b
File.rename(dir_1, dir_2)
File.open(dir_1, "w") {}
end
}
assert_equal([d, dir_1, file_a, file_b, file_c, dir_d], a)
}
end
def test_change_dir_to_symlink_loop
Dir.mktmpdir {|d|
Dir.mkdir(dir_1 = "#{d}/d1")
File.open(file_a = "#{dir_1}/a", "w"){}
File.open(file_b = "#{dir_1}/b", "w"){}
File.open(file_c = "#{dir_1}/c", "w"){}
Dir.mkdir(dir_d = "#{dir_1}/d")
File.open(file_de = "#{dir_d}/e", "w"){}
dir_2 = "#{d}/d2"
a = []
Find.find(d) {|f|
a << f
if f == file_b
File.rename(dir_1, dir_2)
begin
File.symlink("d1", dir_1)
rescue NotImplementedError
skip "symlink is not supported."
end
end
}
assert_equal([d, dir_1, file_a, file_b, file_c, dir_d], a)
}
end
def test_enumerator
Dir.mktmpdir {|d|
File.open("#{d}/a", "w"){}