зеркало из https://github.com/github/ruby.git
`$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:
Родитель
37b90bcdc1
Коммит
02151dad1b
2
load.c
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
|
||||
|
|
Загрузка…
Ссылка в новой задаче