[前][次][番号順一覧][スレッド一覧]

ruby-changes:60743

From: Nobuyoshi <ko1@a...>
Date: Sat, 11 Apr 2020 15:13:25 +0900 (JST)
Subject: [ruby-changes:60743] bae16b4277 (master): Assertions for enumerators of Dir

https://git.ruby-lang.org/ruby.git/commit/?id=bae16b4277

From bae16b427765d237aabd8939557325f1530d623b Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sat, 11 Apr 2020 12:00:24 +0900
Subject: Assertions for enumerators of Dir


diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb
index a3242a6..3e33eef 100644
--- a/test/ruby/test_dir.rb
+++ b/test/ruby/test_dir.rb
@@ -326,6 +326,12 @@ class TestDir < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_dir.rb#L326
     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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_dir.rb#L344
     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 v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]