aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-04-11 12:00:24 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-04-11 12:59:26 +0900
commitbae16b427765d237aabd8939557325f1530d623b (patch)
tree4e9d4f9c2ac651728570b553398a25560d2124b4
parentaade69eaf8f3b08f228f4ac3fbe9c3667f106f4d (diff)
downloadruby-bae16b427765d237aabd8939557325f1530d623b.tar.gz
Assertions for enumerators of Dir
-rw-r--r--test/ruby/test_dir.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb
index a3242a6b3d..3e33eef5e6 100644
--- a/test/ruby/test_dir.rb
+++ b/test/ruby/test_dir.rb
@@ -326,6 +326,12 @@ class TestDir < Test::Unit::TestCase
assert_entries(Dir.open(@root) {|dir| dir.each.to_a})
assert_entries(Dir.foreach(@root).to_a)
assert_raise(ArgumentError) {Dir.foreach(@root+"\0").to_a}
+ newdir = @root+"/new"
+ e = Dir.foreach(newdir)
+ assert_raise(Errno::ENOENT) {e.to_a}
+ Dir.mkdir(newdir)
+ File.write(newdir+"/a", "")
+ assert_equal(%w[. .. a], e.to_a.sort)
end
def test_children
@@ -338,6 +344,12 @@ class TestDir < Test::Unit::TestCase
assert_entries(Dir.open(@root) {|dir| dir.each_child.to_a}, true)
assert_entries(Dir.each_child(@root).to_a, true)
assert_raise(ArgumentError) {Dir.each_child(@root+"\0").to_a}
+ newdir = @root+"/new"
+ e = Dir.each_child(newdir)
+ assert_raise(Errno::ENOENT) {e.to_a}
+ Dir.mkdir(newdir)
+ File.write(newdir+"/a", "")
+ assert_equal(%w[a], e.to_a)
end
def test_dir_enc