diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-12-15 17:21:09 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-12-15 17:21:09 +0000 |
commit | 6aafca91dba6ef3bfe1de2bedadf77fe75b17ef4 (patch) | |
tree | a8d29a60f77c0030a959988857c9bfb7a9870ce6 /test/test_find.rb | |
parent | 79933d6669b0afe72b12a948193b7350bfa06fa6 (diff) | |
download | ruby-6aafca91dba6ef3bfe1de2bedadf77fe75b17ef4.tar.gz |
add tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_find.rb')
-rw-r--r-- | test/test_find.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/test_find.rb b/test/test_find.rb index b68718c709..677a7e14bb 100644 --- a/test/test_find.rb +++ b/test/test_find.rb @@ -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"){} |