various tests: replace BEGIN/require/import by use

That is, turn

    BEGIN {
        require Foo;
        Foo->import(...);
    }

into

    use Foo ...;

(Except for a few tests that did the `require Config; Config->import`
dance without actually using `%Config` anywhere, so I just deleted the
import code.)
This commit is contained in:
Lukas Mai 2025-03-15 10:52:45 +01:00 committed by mauke
parent 650608f18d
commit 8b1b46cdfe
48 changed files with 49 additions and 67 deletions

View File

@ -6,8 +6,8 @@
use strict;
no warnings;
use Config;
BEGIN {
require Config; Config->import;
if (!$::Config{d_setlocale} || $::Config{ccflags} =~ /\bD?NO_LOCALE\b/) {
print "1..0\n";
exit;

View File

@ -7,8 +7,8 @@ my $File;
BEGIN {
$File = __FILE__;
require strict; strict->import();
}
use strict;
use Test::More tests => 12;

2
dist/Safe/t/safe1.t vendored
View File

@ -1,7 +1,7 @@
#!./perl -w
$|=1;
use Config;
BEGIN {
require Config; Config->import;
if ($Config{'extensions'} !~ /\bOpcode\b/ && $Config{'osname'} ne 'VMS') {
print "1..0\n";
exit 0;

2
dist/Safe/t/safe2.t vendored
View File

@ -1,7 +1,7 @@
#!./perl -w
$|=1;
use Config;
BEGIN {
require Config; Config->import;
if ($Config{'extensions'} !~ /\bOpcode\b/ && $Config{'osname'} ne 'VMS') {
print "1..0\n";
exit 0;

2
dist/Safe/t/safe3.t vendored
View File

@ -1,7 +1,7 @@
#!perl -w
use Config;
BEGIN {
require Config; Config->import;
if ($Config{'extensions'} !~ /\bOpcode\b/
&& $Config{'extensions'} !~ /\bPOSIX\b/
&& $Config{'osname'} ne 'VMS')

View File

@ -1,8 +1,7 @@
#!perl
use Config;
BEGIN {
require Config;
Config->import;
if ($Config{'extensions'} !~ /\bOpcode\b/) {
print "1..0\n";
exit 0;

View File

@ -1,7 +1,7 @@
#!perl -w
use Config;
BEGIN {
require Config; Config->import;
if ($Config{'extensions'} !~ /\bOpcode\b/) {
print "1..0\n";
exit 0;

View File

@ -1,8 +1,7 @@
#!perl
use Config;
BEGIN {
require Config;
Config->import;
if ($Config{'extensions'} !~ /\bOpcode\b/) {
print "1..0\n";
exit 0;

View File

@ -1,8 +1,7 @@
#!perl
use Config;
BEGIN {
require Config;
Config->import;
if ($Config{'extensions'} !~ /\bOpcode\b/) {
print "1..0\n";
exit 0;

View File

@ -1,7 +1,7 @@
#!perl -w
$|=1;
use Config;
BEGIN {
require Config; Config->import;
if ($Config{'extensions'} !~ /\bOpcode\b/ && $Config{'osname'} ne 'VMS') {
print "1..0\n";
exit 0;

View File

@ -1,8 +1,7 @@
#!perl
use Config;
BEGIN {
require Config;
Config->import;
if ($Config{'extensions'} !~ /\bOpcode\b/) {
print "1..0\n";
exit 0;

View File

@ -1,7 +1,7 @@
#!perl -w
$|=1;
use Config;
BEGIN {
require Config; Config->import;
if ($Config{'extensions'} !~ /\bOpcode\b/ && $Config{'osname'} ne 'VMS') {
print "1..0\n";
exit 0;

View File

@ -1,8 +1,8 @@
#!perl -w
$|=1;
use Config;
BEGIN {
require Config; Config->import;
if ($Config{'extensions'} !~ /\bOpcode\b/ && $Config{'osname'} ne 'VMS') {
print "1..0\n";
exit 0;

View File

@ -1,7 +1,7 @@
#!./perl -T
use Config;
BEGIN {
require Config; Config->import;
if ($Config{'extensions'} !~ /\bDevel\/Peek\b/) {
print "1..0 # Skip: Devel::Peek was not built\n";
exit 0;

View File

@ -2,15 +2,15 @@
# stdio: open(), tell(), seek(), print(), read() is tested in t/op/lfs.t.
# If you modify/add tests here, remember to update also t/op/lfs.t.
use Config;
BEGIN {
require Config; Config->import;
# Don't bother if there are no quad offsets.
if ($Config{lseeksize} < 8) {
print "1..0 # Skip: no 64-bit file offsets\n";
exit(0);
}
require Fcntl; Fcntl->import(qw(/^O_/ /^SEEK_/));
}
use Fcntl qw(/^O_/ /^SEEK_/);
use strict;
use File::Temp 'tempfile';

View File

@ -1,7 +1,7 @@
#!./perl -w
use Config;
BEGIN {
require Config; Config->import;
if (!$Config{'d_fork'}
# open2/3 supported on win32
&& $^O ne 'MSWin32')

View File

@ -2,8 +2,8 @@
$|=1;
use Config;
BEGIN {
require Config; Config->import;
if ($Config{'extensions'} !~ /\bOpcode\b/ && $Config{'osname'} ne 'VMS') {
print "1..0\n";
exit 0;

View File

@ -1,7 +1,7 @@
#!./perl
use Config;
BEGIN {
require Config; Config->import;
if ($Config{'extensions'} !~ /\bOpcode\b/ && $Config{'osname'} ne 'VMS') {
print "1..0\n";
exit 0;

View File

@ -7,8 +7,8 @@
# the Perl one. So we run the tests in a separate "fresh_perl" process
# with the correct LC_CTYPE set in the environment.
use Config;
BEGIN {
require Config; Config->import;
if ($^O ne 'VMS' and $Config{'extensions'} !~ /\bPOSIX\b/) {
print "1..0\n";
exit 0;

View File

@ -1,7 +1,7 @@
#!./perl
use Config;
BEGIN {
require Config; Config->import;
if ($^O ne 'VMS' and $Config{'extensions'} !~ /\bPOSIX\b/) {
print "1..0\n";
exit 0;

View File

@ -1,7 +1,7 @@
#!./perl -Tw
use Config;
BEGIN {
require Config; Config->import;
if ($^O ne 'VMS' and $Config{'extensions'} !~ /\bPOSIX\b/) {
print "1..0\n";
exit 0;

View File

@ -1,7 +1,7 @@
#!./perl
use Config;
BEGIN {
require Config; Config->import;
if ($Config{'extensions'} !~ /\bSys\/Hostname\b/) {
print "1..0 # Skip: Sys::Hostname was not built\n";
exit 0;

View File

@ -4,8 +4,8 @@
# DAPM Dec 2005
my $threads;
use Config;
BEGIN {
require Config; Config->import;
$threads = $Config{'useithreads'};
# must 'use threads' before 'use Test::More'
eval 'use threads' if $threads;

View File

@ -1,5 +1,5 @@
use Config;
BEGIN {
require Config; Config->import;
if ($Config{'extensions'} !~ /\bXS\/Typemap\b/) {
print "1..0 # Skip: XS::Typemap was not built\n";
exit 0;

View File

@ -3,10 +3,10 @@
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
require Config; Config->import;
require Test::More; Test::More->import;
plan(tests, 12);
}
use Config;
use Test::More;
plan(tests, 12);
require AnyDBM_File;
use Fcntl;

View File

@ -6,9 +6,9 @@ BEGIN {
}
use Test::More;
use Config;
BEGIN {
require Config; Config->import;
if ($Config{'extensions'} !~ /\bSocket\b/ &&
!(($^O eq 'VMS') && $Config{d_socket}))
{
@ -19,8 +19,6 @@ BEGIN {
}
}
use Test::More;
BEGIN { use_ok 'Net::hostent' }
# Remind me to add this to Test::More.

View File

@ -54,8 +54,8 @@ BEGIN {
exit;
}
$| = 1;
require Config; Config->import;
}
use Config;
use feature 'fc';
my @langinfo;

View File

@ -3,10 +3,10 @@
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
require Config; Config->import;
require './test.pl';
require './charset_tools.pl';
}
use Config;
plan 11;

View File

@ -6,7 +6,7 @@ BEGIN {
set_up_inc( qw(. ../lib) );
}
require Config; Config->import;
use Config;
plan(tests => 1);
SKIP: {

View File

@ -4,8 +4,8 @@ BEGIN {
chdir 't' if -d 't';
require './test.pl';
set_up_inc('../lib');
require Config; Config->import;
}
use Config;
if (!$Config{'d_fork'}) {
skip_all("fork required to pipe");
}

View File

@ -3,8 +3,8 @@ BEGIN {
@INC = '../lib' if -d '../lib' && -d '../ext';
require "./test.pl";
require Config; Config->import;
}
use Config;
use strict;
use warnings;

View File

@ -5,11 +5,10 @@ BEGIN {
@INC = '../lib';
require './test.pl';
}
use Config;
plan( tests => 1);
require Config; Config->import;
if (($Config{'extensions'} !~ /\bFcntl\b/) ){
BAIL_OUT("Perl configured without Fcntl module");
}

View File

@ -9,7 +9,6 @@ BEGIN {
chdir 't' if -d 't';
require './test.pl';
set_up_inc('../lib');
require Config; Config->import;
skip_all_without_unicode_tables();
require './charset_tools.pl';
require './loc_tools.pl'; # Contains find_utf8_ctype_locale()

View File

@ -4,9 +4,9 @@ BEGIN {
chdir 't' if -d 't';
require "./test.pl";
set_up_inc( qw(../lib .) );
require Config; Config->import;
require "./loc_tools.pl";
}
use Config;
plan tests => 60;

View File

@ -16,9 +16,9 @@ BEGIN {
chdir 't' if -d 't';
require './test.pl';
set_up_inc('../lib','.','../ext/re');
require Config; Config->import;
skip_all('no re module') unless defined &DynaLoader::boot_DynaLoader;
}
use Config;
# An array is used instead of a hash, so that the tests are carried out in the
# order given by this file. Even-numbered indices are the regexes to compile.

View File

@ -12,7 +12,6 @@ BEGIN {
chdir 't' if -d 't';
require './test.pl';
set_up_inc('../lib');
require Config; Config->import;
skip_all_if_miniperl("no dynamic loading on miniperl, no Encode nor POSIX");
if ($^O eq 'dec_osf') {
skip_all("$^O cannot handle this test");

View File

@ -18,10 +18,10 @@ BEGIN {
chdir 't' if -d 't';
require './test.pl';
set_up_inc('../lib', '.', '../ext/re');
require Config; Config->import;
require './charset_tools.pl';
require './loc_tools.pl';
}
use Config;
skip_all_without_unicode_tables();

View File

@ -18,8 +18,8 @@ BEGIN {
chdir 't' if -d 't';
require './test.pl';
set_up_inc('../lib','.','../ext/re');
require Config; Config->import;
}
use Config;
skip_all('no re module') unless defined &DynaLoader::boot_DynaLoader;
skip_all_without_unicode_tables();

View File

@ -15,7 +15,6 @@ BEGIN {
chdir 't' if -d 't';
require './test.pl';
set_up_inc('../lib', '.', '../ext/re');
require Config; Config->import;
}
skip_all_without_config('useithreads');

View File

@ -4,12 +4,11 @@ BEGIN {
chdir 't' if -d 't';
require './test.pl';
set_up_inc('../lib');
require Config; Config->import;
require constant;
constant->import(constcow => *Config::{NAME});
require './charset_tools.pl';
require './loc_tools.pl';
}
use Config;
use constant constcow => *Config::{NAME};
plan(tests => 281);

View File

@ -45,9 +45,8 @@ BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
require './test.pl';
require Config;
Config->import;
}
use Config;
skip_all_without_config('d_fork');
skip_all("NO_PERL_HASH_ENV or NO_PERL_HASH_SEED_DEBUG set")

View File

@ -4,9 +4,8 @@ BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
require './test.pl';
require Config;
Config->import;
}
use Config;
skip_all_without_config('d_fork');
skip_all("This perl is built with NO_PERL_RAND_SEED")

View File

@ -3,10 +3,8 @@
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
require Config;
Config->import;
}
use Config;
use strict;
use warnings;

View File

@ -7,11 +7,10 @@
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
require Config; Config->import;
require "./test.pl";
require "./loc_tools.pl";
}
BEGIN { require "./test.pl"; require "./loc_tools.pl"; }
use Config;
# due to a bug in VMS's piping which makes it impossible for runperl()

View File

@ -5,8 +5,8 @@ BEGIN {
set_up_inc('../lib', '.', '../ext/re');
require './charset_tools.pl';
require './loc_tools.pl';
require Config; Config->import;
}
use Config;
use strict;
use warnings;

View File

@ -10,7 +10,6 @@ BEGIN {
set_up_inc('../lib');
skip_all_without_unicode_tables();
skip_all_if_miniperl("miniperl, no Unicode::Normalize");
require Config; Config->import;
require './charset_tools.pl';
require './loc_tools.pl'; # Contains find_utf8_ctype_locale()
}

View File

@ -4,7 +4,6 @@ BEGIN {
chdir 't' if -d 't';
require './test.pl';
set_up_inc( '../lib' );
require Config; Config->import;
require './charset_tools.pl';
require './loc_tools.pl';
}

View File

@ -8,8 +8,6 @@
BEGIN {
chdir 't' if -d 't';
@INC = '../lib';
require Config; Config->import;
require File::Temp; File::Temp->import(qw/:POSIX/);
require Win32;
($::os_id, $::os_major) = ( Win32::GetOSVersion() )[ 4, 1 ];
@ -22,6 +20,8 @@ BEGIN {
require './test.pl';
}
use Config;
use File::Temp qw/:POSIX/;
skip_all "requires compilation with PERL_IMPLICIT_SYS"
unless $Config{ccflags} =~/(?:\A|\s)-DPERL_IMPLICIT_SYS\b/;