From 135a171ce11dc56d037bfc9c5c50b006042621c4 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 16 Feb 2016 08:34:47 +0000 Subject: 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 --- test/ruby/test_dir.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/ruby/test_dir.rb') diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb index 0cc5a6aa9b..88033158b7 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 -- cgit v1.2.3