1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Use rb_warn_deprecated for File.exists? and Dir.exists?

This commit is contained in:
Nobuyoshi Nakada 2020-04-06 21:37:42 +09:00
parent b66d7d9be5
commit a58bbd6a51
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
5 changed files with 5 additions and 32 deletions

2
dir.c
View file

@ -3498,7 +3498,7 @@ rb_file_directory_p(void)
static VALUE
rb_dir_exists_p(VALUE obj, VALUE fname)
{
rb_warning("Dir.exists? is a deprecated name, use Dir.exist? instead");
rb_warn_deprecated("", "Dir.exist?");
return rb_file_directory_p(obj, fname);
}

8
file.c
View file

@ -1782,16 +1782,16 @@ rb_file_exist_p(VALUE obj, VALUE fname)
static VALUE
rb_file_exists_p(VALUE obj, VALUE fname)
{
const char *s = "FileTest#";
const char *s = "FileTest#exist?";
if (obj == rb_mFileTest) {
s = "FileTest.";
s = "FileTest.exist?";
}
else if (obj == rb_cFile ||
(RB_TYPE_P(obj, T_CLASS) &&
RTEST(rb_class_inherited_p(obj, rb_cFile)))) {
s = "File.";
s = "File.exist?";
}
rb_warning("%sexists? is a deprecated name, use %sexist? instead", s, s);
rb_warn_deprecated("", s);
return rb_file_exist_p(obj, fname);
}

View file

@ -1,15 +0,0 @@
require_relative '../../spec_helper'
require_relative 'fixtures/common'
require_relative 'shared/exist'
describe "Dir.exists?" do
before :all do
DirSpecs.create_mock_dirs
end
after :all do
DirSpecs.delete_mock_dirs
end
it_behaves_like :dir_exist, :exists?
end

View file

@ -1,6 +0,0 @@
require_relative '../../spec_helper'
require_relative '../../shared/file/exist'
describe "File.exists?" do
it_behaves_like :file_exist, :exists?, File
end

View file

@ -1,6 +0,0 @@
require_relative '../../spec_helper'
require_relative '../../shared/file/exist'
describe "FileTest.exists?" do
it_behaves_like :file_exist, :exists?, FileTest
end