diff options
author | Nobuyoshi Nakada <[email protected]> | 2020-04-11 12:00:24 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2020-04-11 12:59:26 +0900 |
commit | bae16b427765d237aabd8939557325f1530d623b (patch) | |
tree | 4e9d4f9c2ac651728570b553398a25560d2124b4 /test/ruby/test_dir.rb | |
parent | aade69eaf8f3b08f228f4ac3fbe9c3667f106f4d (diff) |
Assertions for enumerators of Dir
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3018
Diffstat (limited to 'test/ruby/test_dir.rb')
-rw-r--r-- | test/ruby/test_dir.rb | 12 |
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 |