From 0762e20f0e44886b683b213f231829db9fee8c5b Mon Sep 17 00:00:00 2001 From: Dan Book Date: Tue, 13 Aug 2024 00:36:52 -0400 Subject: [PATCH 1/2] remove use of apostrophe package separator in tests due to upcoming removal in Perl 5.42 (resolves #2085) --- t/mojo/base.t | 2 +- t/mojo/loader.t | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/t/mojo/base.t b/t/mojo/base.t index 106c8526d8..f936f12609 100644 --- a/t/mojo/base.t +++ b/t/mojo/base.t @@ -19,7 +19,7 @@ package Mojo::BaseTestTest; use Mojo::Base 'Mojo::BaseTest'; package Mojo::BaseTestTestTest; -use Mojo::Base "Mojo'BaseTestTest"; +use Mojo::Base 'Mojo::BaseTestTest'; package Mojo::BaseTest::Weak1; use Mojo::Base -base; diff --git a/t/mojo/loader.t b/t/mojo/loader.t index 6dd9df47b8..0356339971 100644 --- a/t/mojo/loader.t +++ b/t/mojo/loader.t @@ -76,8 +76,8 @@ subtest 'Search packages' => sub { }; subtest 'Load' => sub { - ok !load_class("Mojo'LoaderTest::A"), 'loaded successfully'; - ok !!Mojo::LoaderTest::A->can('new'), 'loaded successfully'; + ok !load_class('Mojo::LoaderTest::A'), 'loaded successfully'; + ok !!Mojo::LoaderTest::A->can('new'), 'loaded successfully'; load_class $_ for find_modules 'Mojo::LoaderTest'; ok !!Mojo::LoaderTest::B->can('new'), 'loaded successfully'; ok !!Mojo::LoaderTest::C->can('new'), 'loaded successfully'; From a4e7257dd5734b5e4017740dcd64afe11faac2eb Mon Sep 17 00:00:00 2001 From: Dan Book Date: Tue, 13 Aug 2024 00:46:52 -0400 Subject: [PATCH 2/2] deprecate use of old package separator ' in Mojo::Loader::load_class --- lib/Mojo/Loader.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Mojo/Loader.pm b/lib/Mojo/Loader.pm index 1331dc633f..f65e44adb9 100644 --- a/lib/Mojo/Loader.pm +++ b/lib/Mojo/Loader.pm @@ -4,7 +4,7 @@ use Mojo::Base -strict; use Exporter qw(import); use Mojo::Exception; use Mojo::File qw(path); -use Mojo::Util qw(b64_decode class_to_path); +use Mojo::Util qw(b64_decode class_to_path deprecated); our @EXPORT_OK = qw(data_section file_is_binary find_modules find_packages load_class load_classes); @@ -42,6 +42,9 @@ sub load_class { # Invalid class name return 1 if ($class || '') !~ /^\w(?:[\w:']*\w)?$/; + deprecated + q{Calling Mojo::Loader::load_class with a class name using the old package separator "'" is deprecated; use "::"} + if $class =~ m/'/; # Load if not already loaded return undef if $class->can('new') || eval "require $class; 1";