diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-02-16 08:34:47 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-02-16 08:34:47 +0000 |
commit | 135a171ce11dc56d037bfc9c5c50b006042621c4 (patch) | |
tree | bfb570c21e1926998df8119e8cbc8b1392061ad7 /test | |
parent | 9cedfbcb918176627a9ed0a462480e52c9991c6c (diff) | |
download | ruby-135a171ce11dc56d037bfc9c5c50b006042621c4.tar.gz |
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')
-rw-r--r-- | test/ruby/test_dir.rb | 9 |
1 files changed, 9 insertions, 0 deletions
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 |