lib/Foo/foo.PL
and
PL_files => {
'lib/Foo/foo.PL' => 'lib/Foo/foo.xml',
}
I saw it copy foo.xml into the
blib directory, etc.
I added one more item to PL_files,
re-ran Build.PL, re-ran my tests, and
all of a sudden the xml files were
no longer being copied into blib
thus causing tests to fail.
No worries as all was well again
after I added
$builder->add_build_element('xml');
I suppose I could preprocess the strings before handing them off to is_string():
use Text::Tabs;
use Test::More tests => 1;
use Test::LongString;
# Apply one or more filters.
# N.B. The order in which the filters are applied matters:
my @strings =
map {tr/\n\r\f //s; $_}
map expand($_) =>
map lc($_) =>
<DATA>;
is_string(
$strings[0],
$strings[1],
'Actually differs by one char'
);
__DATA__
This is a test of Test::LongStrings
this is a test of Test::longstring
As far as the _common_prefix_length function is concerned, perhaps using substr would be a bit faster?
while (length($x) && length($y)) {
- my ($x1,$x2) = $x =~/(.)(.*)/s;
- my ($y1,$y2) = $y =~/(.)(.*)/s;
+ my $x1 = substr($x, 0, 1, '');
+ my $y1 = substr($y, 0, 1, '');
if ($x1 eq $y1) {
- $x = $x2;
- $y = $y2;
++$r;
}
I don't do any XS programming, but I do use C often enough
to think learning Inline to be worthwhile and, well, fun. After
my first experience with Inline, I really have to give kudos to those in
My first naive attempt went something like this:
use Inline 'C';
my @integers = (4, 2, 1, 5, 6, 3);
print +choose(\&lessthan, scalar @integers, @integers);
print +choose(\&grtrthan, scalar @integers, @integers);
__DATA__
__C__
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
int lessthan (int a, int b)
{
return (a < b) ? a : b;
}
int grtrthan (int a, int b)
{
return (a > b) ? a : b;
}
int choose( int(*fn)(), size_t count, int first,...)
{
va_list arg_ptr;
int next;
int keep;
va_start(arg_ptr,count);
keep = va_arg(arg_ptr, int);
for(--count; count > 0; --count) {
next = va_arg(arg_ptr, int);
keep = fn(keep, next);
}
return keep;
}
In retrospect, other than as a learning exercise, this wasn't an ideal test of Inline::C. There's no speed advantage over a pure perl implementation. I ended up with something that seems to be half C and half XS:
use Inline 'C';
my @integers = (4, 2, 1, 5, 6, 3);
local $\ = "\n";
print +choose(\&lessthan, @integers);
print +choose(\&grtrthan, @integers);
__DATA__
__C__
#include <stdio.h>
#include <stdlib.h>
int lessthan (int a, int b)
{
return (a < b) ? a : b;
}
int grtrthan (int a, int b)
{
return (a > b) ? a : b;
}
int choose(CV *fn, int first,...)
{
SV *next_sv;
SV *keep_sv;
unsigned int count;
Inline_Stack_Vars;
keep_sv = newSVsv(Inline_Stack_Item(1));
for(count = 2; count < Inline_Stack_Items ; ++count)
{
I32 retval;
dSP;
ENTER;
SAVETMPS;
next_sv = newSVsv(Inline_Stack_Item(count));
PUSHMARK(SP);
XPUSHs(sv_2mortal(newSVsv(keep_sv)));
XPUSHs(sv_2mortal(next_sv));
PUTBACK;
retval = call_sv((SV *)fn, G_SCALAR);
SPAGAIN;
if (retval != 1)
{
croak("Big trouble\n");
}
sv_setsv(keep_sv, POPs);
FREETMPS;
LEAVE;
}
Inline_Stack_Reset;
Inline_Stack_Done;
return (int)SvIV(keep_sv);
}
[sunnydale:~] skuo% prove -Iblib2/lib t/*.t
t/00load.....Perl lib version (v5.8.6) doesn't match executable version (v5.8.0) at/usr/local/lib/perl5/5.8.6/darwin/Config.pm line 32.
Compilation failed in require at/usr/local/lib/perl5/5.8.6/Test/Builder.pm line 18.
It's my fault for having two different versions of
perl: 5.8.6 under
It turns out that $^X is set to the string 'perl' and trips
up my effort at running tests. All's well after setting HARNESS_PERL in my environment to
Perhaps one of the %Config entries should replace $^X inside Test::Harness::Straps (e.g., in &_command)?