Alt-Module-Runtime-ButEUMM

 view release on metacpan or  search on metacpan

lib/Module/Runtime.pm  view on Meta::CPAN

	$module_name_rx is_module_name is_valid_module_name check_module_name
	module_notional_filename require_module
	use_module use_package_optimistically
	$top_module_spec_rx $sub_module_spec_rx
	is_module_spec is_valid_module_spec check_module_spec
	compose_module_name
);
my %export_ok = map { ($_ => undef) } @EXPORT_OK;
sub import {
	my $me = shift;
	my $callpkg = caller(0);
	my $errs = "";
	foreach(@_) {
		if(exists $export_ok{$_}) {
			# We would need to do "no strict 'refs'" here
			# if we had enabled strict at file scope.
			if(/\A\$(.*)\z/s) {
				*{$callpkg."::".$1} = \$$1;
			} else {
				*{$callpkg."::".$_} = \&$_;
			}
		} else {
			$errs .= "\"$_\" is not exported by the $me module\n";
		}
	}
	if($errs ne "") {
		die "${errs}Can't continue after import errors ".
			"at @{[(caller(0))[1]]} line @{[(caller(0))[2]]}.\n";
	}
}

# Logic duplicated from Params::Classify.  Duplicating it here avoids
# an extensive and potentially circular dependency graph.
sub _is_string($) {
	my($arg) = @_;
	return defined($arg) && ref(\$arg) eq "SCALAR";
}

t/lib/t/Eval.pm  view on Meta::CPAN


use warnings;
use strict;

use Test::More 0.41;

sub _ok_no_eval() {
	my $lastsub = "";
	my $i = 0;
	while(1) {
		my @c = caller($i);
		unless(@c) {
			ok 0;
			diag "failed to find main program in stack trace";
			return;
		}
		my $sub = $c[3];
		if($sub eq "main::eval_test") {
			ok 1;
			return;
		}

t/rm.t  view on Meta::CPAN


# module file scope sees scalar context regardless of calling context
eval { require_module("t::Context"); 1 };
is $@, "";

# lexical hints don't leak through
my $have_runtime_hint_hash = "$]" >= 5.009004;
sub test_runtime_hint_hash($$) {
	SKIP: {
		skip "no runtime hint hash", 1 unless $have_runtime_hint_hash;
		is +((caller(0))[10] || {})->{$_[0]}, $_[1];
	}
}
SKIP: {
	skip "core bug makes this test crash", 13
		if "$]" >= 5.008 && "$]" < 5.008004;
	skip "can't work around hint leakage in pure Perl", 13
		if "$]" >= 5.009004 && "$]" < 5.010001;
	$^H |= 0x20000 if "$]" < 5.009004;
	$^H{"Module::Runtime/test_a"} = 1;
	is $^H{"Module::Runtime/test_a"}, 1;

t/um.t  view on Meta::CPAN


# module file scope sees scalar context regardless of calling context
$result = eval { use_module("t::Context"); 1 };
is $@, "";

# lexical hints don't leak through
my $have_runtime_hint_hash = "$]" >= 5.009004;
sub test_runtime_hint_hash($$) {
	SKIP: {
		skip "no runtime hint hash", 1 unless $have_runtime_hint_hash;
		is +((caller(0))[10] || {})->{$_[0]}, $_[1];
	}
}
SKIP: {
	skip "core bug makes this test crash", 13
		if "$]" >= 5.008 && "$]" < 5.008004;
	skip "can't work around hint leakage in pure Perl", 13
		if "$]" >= 5.009004 && "$]" < 5.010001;
	$^H |= 0x20000 if "$]" < 5.009004;
	$^H{"Module::Runtime/test_a"} = 1;
	is $^H{"Module::Runtime/test_a"}, 1;

t/upo.t  view on Meta::CPAN

is $@, "";
is $result, "t::Simple";
no strict "refs";
ok defined(${"t::Simple::VERSION"});

# lexical hints don't leak through
my $have_runtime_hint_hash = "$]" >= 5.009004;
sub test_runtime_hint_hash($$) {
	SKIP: {
		skip "no runtime hint hash", 1 unless $have_runtime_hint_hash;
		is +((caller(0))[10] || {})->{$_[0]}, $_[1];
	}
}
SKIP: {
	skip "core bug makes this test crash", 13
		if "$]" >= 5.008 && "$]" < 5.008004;
	skip "can't work around hint leakage in pure Perl", 13
		if "$]" >= 5.009004 && "$]" < 5.010001;
	$^H |= 0x20000 if "$]" < 5.009004;
	$^H{"Module::Runtime/test_a"} = 1;
	is $^H{"Module::Runtime/test_a"}, 1;



( run in 0.267 second using v1.01-cache-2.11-cpan-26ccb49234f )