`$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