Skip to content

Commit ff2d799

Browse files
committed
Refactor have_compiler and have_cplusplus
1 parent bb608fa commit ff2d799

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

t/lib/MakeMaker/Test/Utils.pm

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -351,32 +351,27 @@ Returns true if there is a compiler available for XS builds.
351351
352352
=cut
353353

354-
sub have_compiler {
355-
my $have_compiler = 0;
356-
eval {
357-
require ExtUtils::CBuilder;
358-
my $cb = ExtUtils::CBuilder->new(quiet=>1);
359-
$have_compiler = $cb->have_compiler;
360-
};
361-
return $have_compiler;
362-
}
354+
sub have_compiler { run_cbuilder('have_compiler'); }
363355

364356
=item have_cplusplus
365357
366-
$have_compiler = have_cplusplus;
358+
$have_cplusplus = have_cplusplus;
367359
368360
Returns true if there is a C++ compiler available for XS builds.
369361
370362
=cut
371363

372-
sub have_cplusplus {
373-
my $have_cplusplus = 0;
364+
sub have_cplusplus { run_cbuilder('have_cplusplus'); }
365+
366+
sub run_cbuilder {
367+
my $method = shift;
368+
my $retval = 0;
374369
eval {
375370
require ExtUtils::CBuilder;
376371
my $cb = ExtUtils::CBuilder->new(quiet=>1);
377-
$have_cplusplus = $cb->have_cplusplus;
372+
$retval = $cb->$method;
378373
};
379-
return $have_cplusplus;
374+
return $retval;
380375
}
381376

382377
=item slurp

0 commit comments

Comments
 (0)