Improve ArgumentError message for Module#set_temporary_name

This commit is contained in:
Benoit Daloze 2023-07-06 16:34:28 +02:00
Родитель 9ee1877e4a
Коммит 055f7219bc
2 изменённых файлов: 5 добавлений и 5 удалений

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

@ -29,14 +29,14 @@ ruby_version_is "3.3" do
it "can't assign a constant name as a temporary name" do
m = Module.new
-> { m.set_temporary_name("Object") }.should raise_error(ArgumentError, "name must not be valid constant path")
-> { m.set_temporary_name("Object") }.should raise_error(ArgumentError, "the temporary name must not be a constant path to avoid confusion")
end
it "can't assign a constant path as a temporary name" do
m = Module.new
-> { m.set_temporary_name("A::B") }.should raise_error(ArgumentError, "name must not be valid constant path")
-> { m.set_temporary_name("::A") }.should raise_error(ArgumentError, "name must not be valid constant path")
-> { m.set_temporary_name("::A::B") }.should raise_error(ArgumentError, "name must not be valid constant path")
-> { m.set_temporary_name("A::B") }.should raise_error(ArgumentError, "the temporary name must not be a constant path to avoid confusion")
-> { m.set_temporary_name("::A") }.should raise_error(ArgumentError, "the temporary name must not be a constant path to avoid confusion")
-> { m.set_temporary_name("::A::B") }.should raise_error(ArgumentError, "the temporary name must not be a constant path to avoid confusion")
end
it "can't assign name to permanent module" do

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

@ -230,7 +230,7 @@ rb_mod_set_temporary_name(VALUE mod, VALUE name)
}
if (is_constant_path(name)) {
rb_raise(rb_eArgError, "name must not be valid constant path");
rb_raise(rb_eArgError, "the temporary name must not be a constant path to avoid confusion");
}
// Set the temporary classpath to the given name: