`$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 коммит произвёл Kazuhiro NISHIYAMA
Родитель 37b90bcdc1
Коммит 02151dad1b
2 изменённых файлов: 5 добавлений и 1 удалений

2
load.c
Просмотреть файл

@ -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);

Просмотреть файл

@ -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