Skip to content

Commit 14c8f36

Browse files
committed
Refactor have_compiler and have_cplusplus
1 parent 504aaf8 commit 14c8f36

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
@@ -357,32 +357,27 @@ Returns true if there is a compiler available for XS builds.
357357
358358
=cut
359359

360-
sub have_compiler {
361-
my $have_compiler = 0;
362-
eval {
363-
require ExtUtils::CBuilder;
364-
my $cb = ExtUtils::CBuilder->new(quiet=>1);
365-
$have_compiler = $cb->have_compiler;
366-
};
367-
return $have_compiler;
368-
}
360+
sub have_compiler { run_cbuilder('have_compiler'); }
369361

370362
=item have_cplusplus
371363
372-
$have_compiler = have_cplusplus;
364+
$have_cplusplus = have_cplusplus;
373365
374366
Returns true if there is a C++ compiler available for XS builds.
375367
376368
=cut
377369

378-
sub have_cplusplus {
379-
my $have_cplusplus = 0;
370+
sub have_cplusplus { run_cbuilder('have_cplusplus'); }
371+
372+
sub run_cbuilder {
373+
my $method = shift;
374+
my $retval = 0;
380375
eval {
381376
require ExtUtils::CBuilder;
382377
my $cb = ExtUtils::CBuilder->new(quiet=>1);
383-
$have_cplusplus = $cb->have_cplusplus;
378+
$retval = $cb->$method;
384379
};
385-
return $have_cplusplus;
380+
return $retval;
386381
}
387382

388383
=item slurp

0 commit comments

Comments
 (0)