From 02151dad1ba324fac5f8e9459334164d01893124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Sun, 4 Aug 2019 13:09:30 +0200 Subject: [PATCH] `$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. --- load.c | 2 +- test/ruby/test_require.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/load.c b/load.c index cf3adcbb3e..d6616fc5cd 100644 --- a/load.c +++ b/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); diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb index 30c07b9e5c..973d9c92f1 100644 --- a/test/ruby/test_require.rb +++ b/test/ruby/test_require.rb @@ -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