Alt-Devel-CallParser-ButWorking
view release on metacpan or search on metacpan
lib/Devel/CallParser.pm view on Meta::CPAN
This header is only available on Perl versions 5.13.8 and higher.
=item callparser_linkable
List of names of files that must be used as additional objects when
linking an XS module that uses the C functions supplied by this module.
This list will be empty on many platforms.
=cut
sub callparser_linkable() {
require DynaLoader::Functions;
DynaLoader::Functions->VERSION(0.001);
return DynaLoader::Functions::linkable_for_module(__PACKAGE__);
}
=back
=head1 C FUNCTIONS
=over
t/LoadXS.pm view on Meta::CPAN
use strict;
use DynaLoader ();
use ExtUtils::CBuilder ();
use ExtUtils::ParseXS ();
use File::Spec ();
our @todelete;
END { unlink @todelete; }
sub load_xs($$$) {
my($basename, $dir, $extralibs) = @_;
my $xs_file = File::Spec->catdir("t", "$basename.xs");
my $c_file = File::Spec->catdir("t", "$basename.c");
ExtUtils::ParseXS::process_file(
filename => $xs_file,
output => $c_file,
);
push @todelete, $c_file;
my $cb = ExtUtils::CBuilder->new(quiet => 1);
my $o_file = $cb->compile(source => $c_file);
t/WriteHeader.pm view on Meta::CPAN
use warnings;
use strict;
use File::Spec ();
use IO::File 1.03 ();
our @todelete;
END { unlink @todelete; }
sub write_header($$$) {
my($basename, $outdir, $prefix) = @_;
require Devel::CallParser;
no strict "refs";
my $content = &{"Devel::CallParser::${basename}_h"}();
my $h_file = File::Spec->catfile($outdir, "${prefix}_${basename}.h");
push @todelete, $h_file;
my $fh = IO::File->new($h_file, "w") or die $!;
$fh->printflush($content) or die $!;
$fh->close or die $!;
}
t/listquote.t view on Meta::CPAN
is $foo_ret, "z";
*wibble::baz = \&foo; *wibble::baz = \&foo;
$foo_got = undef;
eval q{package wibble; $foo_ret = baz:ab cd:;};
is $@, "";
is_deeply $foo_got, [ "xyz", "a", "b", " ", "c", "d" ];
is $foo_ret, "z";
sub bin($$) { $foo_got = [ @_ ]; return "z"; }
$foo_got = undef;
eval q{$foo_ret = bin 1, 2;};
is $@, "";
is_deeply $foo_got, [ 1, 2 ];
is $foo_ret, "z";
$foo_got = undef;
eval q{$foo_ret = bin 1;};
isnt $@, "";
t/multiblock.t view on Meta::CPAN
t::WriteHeader::write_header("callparser0", "t", "multiblock");
ok 1;
require_ok "Devel::CallParser";
t::LoadXS::load_xs("multiblock", "t",
[Devel::CallParser::callparser_linkable()]);
ok 1;
my @events;
sub my_if($$$) { $_[0]->() ? $_[1]->() : $_[2]->() }
t::multiblock::cv_set_call_parser_multiblock(\&my_if);
@events = ();
eval q{
push @events, "a";
my $x = "x".my_if({
1;
} {
"c";
} {
use t::LoadXS ();
use t::WriteHeader ();
t::WriteHeader::write_header("callparser1", "t", "proto");
ok 1;
require_ok "Devel::CallParser";
t::LoadXS::load_xs("proto", "t", [Devel::CallParser::callparser_linkable()]);
ok 1;
my @three = qw(a b c);
sub unary($) { }
sub noproto { }
sub foo { [ map { ref($_) || $_ } @_ ] }
is_deeply scalar(eval(q{foo()})), [];
is_deeply scalar(eval(q{foo(1,2,3)})), [1,2,3];
is_deeply scalar(eval(q{[ foo ]})), [[]];
is_deeply scalar(eval(q{[ foo 1,2,3 ]})), [[1,2,3]];
is_deeply scalar(eval(q{[ foo @three,4 ]})), [[qw(a b c),4]];
is_deeply scalar(eval(q{[ foo {} ]})), [["HASH"]];
is_deeply scalar(eval(q{[ foo {} 1 ]})), undef;
t/stdargs.t view on Meta::CPAN
t::WriteHeader::write_header("callparser1", "t", "stdargs");
ok 1;
require_ok "Devel::CallParser";
t::LoadXS::load_xs("stdargs", "t", [Devel::CallParser::callparser_linkable()]);
ok 1;
my @three = qw(a b c);
my @five = qw(a b c d e);
sub par_() { [@_] }
sub par_s($) { [@_] }
sub par_ss($$) { [@_] }
sub par_l(@) { [@_] }
t::stdargs::cv_set_call_parser_parenthesised(\&par_);
t::stdargs::cv_set_call_parser_parenthesised(\&par_s);
t::stdargs::cv_set_call_parser_parenthesised(\&par_ss);
t::stdargs::cv_set_call_parser_parenthesised(\&par_l);
is_deeply scalar(eval(q{par_()})), [];
is_deeply scalar(eval(q{par_(1)})), undef;
is_deeply scalar(eval(q{par_(@three)})), undef;
is_deeply scalar(eval(q{par_(@three, @five)})), undef;
is_deeply scalar(eval(q{par_((9,8,7))})), undef;
t/stdargs.t view on Meta::CPAN
is_deeply scalar(eval(q{par_l(@three, @five)})), [qw(a b c a b c d e)];
is_deeply scalar(eval(q{par_l((9,8,7))})), [9,8,7];
is_deeply scalar(eval(q{par_l((9,8,7), (6,5,4))})), [9,8,7,6,5,4];
is_deeply scalar(eval(q{par_l})), undef;
is_deeply scalar(eval(q{par_l 1})), undef;
is_deeply scalar(eval(q{[ par_l 1, 2 ]})), undef;
is_deeply scalar(eval(q{[ par_l @three, @five ]})), undef;
is_deeply scalar(eval(q{[ par_l +(9,8,7) ]})), undef;
is_deeply scalar(eval(q{[ par_l +(9,8,7), (6,5,4) ]})), undef;
sub nul_() { [@_] }
sub nul_s($) { [@_] }
sub nul_ss($$) { [@_] }
sub nul_l(@) { [@_] }
t::stdargs::cv_set_call_parser_nullary(\&nul_);
t::stdargs::cv_set_call_parser_nullary(\&nul_s);
t::stdargs::cv_set_call_parser_nullary(\&nul_ss);
t::stdargs::cv_set_call_parser_nullary(\&nul_l);
is_deeply scalar(eval(q{nul_()})), [];
is_deeply scalar(eval(q{nul_(1)})), undef;
is_deeply scalar(eval(q{nul_(@three)})), undef;
is_deeply scalar(eval(q{nul_(@three, @five)})), undef;
is_deeply scalar(eval(q{nul_((9,8,7))})), undef;
t/stdargs.t view on Meta::CPAN
is_deeply scalar(eval(q{nul_l(@three, @five)})), [qw(a b c a b c d e)];
is_deeply scalar(eval(q{nul_l((9,8,7))})), [9,8,7];
is_deeply scalar(eval(q{nul_l((9,8,7), (6,5,4))})), [9,8,7,6,5,4];
is_deeply scalar(eval(q{nul_l})), [];
is_deeply scalar(eval(q{nul_l 1})), undef;
is_deeply scalar(eval(q{[ nul_l 1, 2 ]})), undef;
is_deeply scalar(eval(q{[ nul_l @three, @five ]})), undef;
is_deeply scalar(eval(q{[ nul_l !(9,8,7) ]})), undef;
is_deeply scalar(eval(q{[ nul_l !(9,8,7), (6,5,4) ]})), undef;
sub una_() { [@_] }
sub una_s($) { [@_] }
sub una_ss($$) { [@_] }
sub una_l(@) { [@_] }
t::stdargs::cv_set_call_parser_unary(\&una_);
t::stdargs::cv_set_call_parser_unary(\&una_s);
t::stdargs::cv_set_call_parser_unary(\&una_ss);
t::stdargs::cv_set_call_parser_unary(\&una_l);
is_deeply scalar(eval(q{una_()})), [];
is_deeply scalar(eval(q{una_(1)})), undef;
is_deeply scalar(eval(q{una_(@three)})), undef;
is_deeply scalar(eval(q{una_(@three, @five)})), undef;
is_deeply scalar(eval(q{una_((9,8,7))})), undef;
t/stdargs.t view on Meta::CPAN
is_deeply scalar(eval(q{una_l(@three, @five)})), [qw(a b c a b c d e)];
is_deeply scalar(eval(q{una_l((9,8,7))})), [9,8,7];
is_deeply scalar(eval(q{una_l((9,8,7), (6,5,4))})), [9,8,7,6,5,4];
is_deeply scalar(eval(q{una_l})), [];
is_deeply scalar(eval(q{una_l 1})), [1];
is_deeply scalar(eval(q{[ una_l 1, 2 ]})), [[1],2];
is_deeply scalar(eval(q{[ una_l @three, @five ]})), [[qw(a b c)],qw(a b c d e)];
is_deeply scalar(eval(q{[ una_l +(9,8,7) ]})), [[9,8,7]];
is_deeply scalar(eval(q{[ una_l +(9,8,7), (6,5,4) ]})), [[9,8,7],6,5,4];
sub lis_() { [@_] }
sub lis_s($) { [@_] }
sub lis_ss($$) { [@_] }
sub lis_l(@) { [@_] }
t::stdargs::cv_set_call_parser_list(\&lis_);
t::stdargs::cv_set_call_parser_list(\&lis_s);
t::stdargs::cv_set_call_parser_list(\&lis_ss);
t::stdargs::cv_set_call_parser_list(\&lis_l);
is_deeply scalar(eval(q{lis_()})), [];
is_deeply scalar(eval(q{lis_(1)})), undef;
is_deeply scalar(eval(q{lis_(@three)})), undef;
is_deeply scalar(eval(q{lis_(@three, @five)})), undef;
is_deeply scalar(eval(q{lis_((9,8,7))})), undef;
t/stdargs.t view on Meta::CPAN
is_deeply scalar(eval(q{lis_l(@three, @five)})), [qw(a b c a b c d e)];
is_deeply scalar(eval(q{lis_l((9,8,7))})), [9,8,7];
is_deeply scalar(eval(q{lis_l((9,8,7), (6,5,4))})), [9,8,7,6,5,4];
is_deeply scalar(eval(q{lis_l})), [];
is_deeply scalar(eval(q{lis_l 1})), [1];
is_deeply scalar(eval(q{[ lis_l 1, 2 ]})), [[1,2]];
is_deeply scalar(eval(q{[ lis_l @three, @five ]})), [[qw(a b c),qw(a b c d e)]];
is_deeply scalar(eval(q{[ lis_l +(9,8,7) ]})), [[9,8,7]];
is_deeply scalar(eval(q{[ lis_l +(9,8,7), (6,5,4) ]})), [[9,8,7,6,5,4]];
sub blo_() { [@_] }
sub blo_s($) { [@_] }
sub blo_ss($$) { [@_] }
sub blo_l(@) { [@_] }
t::stdargs::cv_set_call_parser_block_list(\&blo_);
t::stdargs::cv_set_call_parser_block_list(\&blo_s);
t::stdargs::cv_set_call_parser_block_list(\&blo_ss);
t::stdargs::cv_set_call_parser_block_list(\&blo_l);
is_deeply scalar(eval(q{blo_()})), [];
is_deeply scalar(eval(q{blo_(1)})), undef;
is_deeply scalar(eval(q{blo_(@three)})), undef;
is_deeply scalar(eval(q{blo_(@three, @five)})), undef;
is_deeply scalar(eval(q{blo_((9,8,7))})), undef;
( run in 0.258 second using v1.01-cache-2.11-cpan-65fba6d93b7 )