Skip to content

Commit 83002ed

Browse files
committed
Refactor have_compiler and have_cplusplus
1 parent e06e7f7 commit 83002ed

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
@@ -352,32 +352,27 @@ Returns true if there is a compiler available for XS builds.
352352
353353
=cut
354354

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

365357
=item have_cplusplus
366358
367-
$have_compiler = have_cplusplus;
359+
$have_cplusplus = have_cplusplus;
368360
369361
Returns true if there is a C++ compiler available for XS builds.
370362
371363
=cut
372364

373-
sub have_cplusplus {
374-
my $have_cplusplus = 0;
365+
sub have_cplusplus { run_cbuilder('have_cplusplus'); }
366+
367+
sub run_cbuilder {
368+
my $method = shift;
369+
my $retval = 0;
375370
eval {
376371
require ExtUtils::CBuilder;
377372
my $cb = ExtUtils::CBuilder->new(quiet=>1);
378-
$have_cplusplus = $cb->have_cplusplus;
373+
$retval = $cb->$method;
379374
};
380-
return $have_cplusplus;
375+
return $retval;
381376
}
382377

383378
=item slurp

0 commit comments

Comments
 (0)