From 096137e84fcb3a01089785bb2b8b621f3f7e996f Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 13 Apr 2016 05:47:49 +0000 Subject: [PATCH] file.c: File.empty? * file.c (Init_File): add alias File.empty? to File.zero?. [Feature #9969] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54559 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ file.c | 1 + test/ruby/test_file_exhaustive.rb | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/ChangeLog b/ChangeLog index f704ffef55..dc21137af3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Apr 13 14:47:47 2016 Nobuyoshi Nakada + + * file.c (Init_File): add alias File.empty? to File.zero?. + [Feature #9969] + Wed Apr 13 14:36:24 2016 Nobuyoshi Nakada * parse.y (assign_in_cond): allow multiple assignment in diff --git a/file.c b/file.c index bcadaefd9e..f2e299623f 100644 --- a/file.c +++ b/file.c @@ -5886,6 +5886,7 @@ Init_File(void) define_filetest_function("executable_real?", rb_file_executable_real_p, 1); define_filetest_function("file?", rb_file_file_p, 1); define_filetest_function("zero?", rb_file_zero_p, 1); + define_filetest_function("empty?", rb_file_zero_p, 1); define_filetest_function("size?", rb_file_size_p, 1); define_filetest_function("size", rb_file_s_size, 1); define_filetest_function("owned?", rb_file_owned_p, 1); diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb index 3e030309b6..4538cf3b61 100644 --- a/test/ruby/test_file_exhaustive.rb +++ b/test/ruby/test_file_exhaustive.rb @@ -399,6 +399,13 @@ class TestFileExhaustive < Test::Unit::TestCase assert_file.not_zero?(nofile) end + def test_empty_p + assert_nothing_raised { File.empty?(@dir) } + assert_file.not_empty?(regular_file) + assert_file.empty?(zerofile) + assert_file.not_empty?(nofile) + end + def test_size_p assert_nothing_raised { File.size?(@dir) } assert_equal(3, File.size?(regular_file))