diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-25 02:50:21 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-25 02:50:21 +0000 |
commit | 5f5eebf771ac9989b8a2ad3d1cd67208624225fb (patch) | |
tree | 55ea82cf0a92a02b4aa277e6469d832ffd0fa714 /test/ruby | |
parent | b8845333c5ec6a51786f319108a39c4d192e0039 (diff) | |
download | ruby-5f5eebf771ac9989b8a2ad3d1cd67208624225fb.tar.gz |
dir.c: Dir.each_child and Dir.children
* dir.c (dir_s_each_child, dir_s_children): Dir.each_child and
Dir.children which are similar to Dir.foreach and Dir.entries
respectively, except to exclude "." and "..". [Feature #11302]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_dir.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb index 052f67ed4b..69daa766a4 100644 --- a/test/ruby/test_dir.rb +++ b/test/ruby/test_dir.rb @@ -214,9 +214,11 @@ class TestDir < Test::Unit::TestCase assert_equal(files, Dir.open(@root) {|d| Dir.glob("*/*.c", base: d)}.sort) end - def assert_entries(entries) + def assert_entries(entries, children = false) entries.sort! - assert_equal(%w(. ..) + ("a".."z").to_a, entries) + expected = ("a".."z").to_a + expected = %w(. ..) + expected unless children + assert_equal(expected, entries) end def test_entries @@ -228,6 +230,14 @@ class TestDir < Test::Unit::TestCase assert_entries(Dir.foreach(@root).to_a) end + def test_children + assert_entries(Dir.children(@root), true) + end + + def test_each_child + assert_entries(Dir.each_child(@root).to_a, true) + end + def test_dir_enc dir = Dir.open(@root, encoding: "UTF-8") begin |