summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-16 08:34:47 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-16 08:34:47 +0000
commit135a171ce11dc56d037bfc9c5c50b006042621c4 (patch)
treebfb570c21e1926998df8119e8cbc8b1392061ad7 /test/ruby
parent9cedfbcb918176627a9ed0a462480e52c9991c6c (diff)
dir.c: Dir.empty?
* dir.c (rb_dir_s_empty_p): add Dir.empty? method, which tells the argument is the name of an empty directory. [Feature #10121] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_dir.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb
index 0cc5a6a..8803315 100644
--- a/test/ruby/test_dir.rb
+++ b/test/ruby/test_dir.rb
@@ -331,4 +331,13 @@ class TestDir < Test::Unit::TestCase
end
}
end
+
+ def test_empty?
+ assert_not_send([Dir, :empty?, @root])
+ assert_send([Dir, :empty?, File.join(@root, "a")])
+ open(File.join(@root, "a", "..."), "w") {}
+ assert_not_send([Dir, :empty?, File.join(@root, "a")])
+ assert_raise(Errno::ENOENT) {Dir.empty?(@nodir)}
+ assert_not_send([Dir, :empty?, File.join(@root, "b")])
+ end
end