From bae16b427765d237aabd8939557325f1530d623b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 11 Apr 2020 12:00:24 +0900 Subject: Assertions for enumerators of Dir --- test/ruby/test_dir.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 -- cgit v1.2.3