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

$LOAD_PATH.resolve_feature_path should not raise

I think it's more friendly and easier to work with to return `nil` when
the feature is not found in the $LOAD_PATH.
This commit is contained in:
David Rodríguez 2019-08-04 13:09:30 +02:00 committed by Kazuhiro NISHIYAMA
parent 37b90bcdc1
commit 02151dad1b
Notes: git 2021-02-16 18:11:52 +09:00
2 changed files with 5 additions and 1 deletions

2
load.c
View file

@ -991,7 +991,7 @@ rb_resolve_feature_path(VALUE klass, VALUE fname)
sym = ID2SYM(rb_intern("so"));
break;
default:
load_failed(fname);
return Qnil;
}
return rb_ary_new_from_args(2, sym, path);

View file

@ -857,5 +857,9 @@ class TestRequire < Test::Unit::TestCase
$:.replace(paths)
$".replace(loaded)
end
def test_resolve_feature_path_with_missing_feature
assert_nil($LOAD_PATH.resolve_feature_path("superkalifragilisticoespialidoso"))
end
end
end