my $b = eval { ExtUtils::CBuilder->new(quiet => 1) };
ok( $b, "got CBuilder object" ) or diag $@;
-my $bogus_path = 'djaadjfkadjkfajdf';
-my $run_perl = "$perl -e1 --";
# test missing compiler
-$b->{config}{cc} = $bogus_path;
-$b->{config}{ld} = $bogus_path;
-
-$b->{have_cc} = undef;
-is( $b->have_compiler, 0, "have_compiler: fake missing cc" );
-$b->{have_cxx} = undef;
-is( $b->have_cplusplus, 0, "have_cplusplus: fake missing c++" );
+{
+my $b1 = ExtUtils::CBuilder->new(quiet => 1);
+configure_fake_missing_compilers($b1);
+is( $b1->have_compiler, 0, "have_compiler: fake missing cc" );
+}
+{
+my $b2 = ExtUtils::CBuilder->new(quiet => 1);
+configure_fake_missing_compilers($b2);
+is( $b2->have_cplusplus, 0, "have_cplusplus: fake missing c++" );
+}
# test found compiler
-$b->{config}{cc} = $run_perl;
-$b->{config}{ld} = $run_perl;
-$b->{config}{cxx} = $run_perl;
-$b->{have_cc} = undef;
-is( $b->have_compiler, 1, "have_compiler: fake present cc" );
-$b->{have_cxx} = undef;
-is( $b->have_cplusplus, 1, "have_cpp_compiler: fake present c++" );
+{
+my $b3 = ExtUtils::CBuilder->new(quiet => 1);
+configure_fake_present_compilers($b3);
+is( $b3->have_compiler, 1, "have_compiler: fake present cc" );
+}
+{
+my $b4 = ExtUtils::CBuilder->new(quiet => 1);
+configure_fake_present_compilers($b4);
+is( $b4->have_cplusplus, 1, "have_cpp_compiler: fake present c++" );
+}
# test missing cpp compiler
pass( "OS type not yet listed for $^O" );
}
}
+
+sub configure_fake_missing_compilers {
+ my $b = shift;
+ my $bogus_path = 'djaadjfkadjkfajdf';
+ $b->{config}{cc} = $bogus_path;
+ $b->{config}{ld} = $bogus_path;
+ $b->{have_cc} = undef;
+ $b->{have_cxx} = undef;
+}
+
+sub configure_fake_present_compilers {
+ my $b = shift;
+ my $run_perl = "$perl -e1 --";
+ $b->{config}{cc} = $run_perl;
+ $b->{config}{ld} = $run_perl;
+ $b->{config}{cxx} = $run_perl;
+ $b->{have_cc} = undef;
+ $b->{have_cxx} = undef;
+}