xref: /openbsd-src/gnu/usr.bin/perl/dist/ExtUtils-CBuilder/t/03-cplusplus.t (revision 91f110e064cd7c194e59e019b83bb7496c1c84d4)
1#! perl -w
2
3use strict;
4use Test::More;
5BEGIN {
6  if ($^O eq 'VMS') {
7    # So we can get the return value of system()
8    require vmsish;
9    import vmsish;
10  }
11}
12use ExtUtils::CBuilder;
13use File::Spec;
14
15# TEST does not like extraneous output
16my $quiet = $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE};
17my ($source_file, $object_file, $lib_file);
18
19my $b = ExtUtils::CBuilder->new(quiet => $quiet);
20
21# test plan
22if ( ! $b->have_cplusplus ) {
23  plan skip_all => "no compiler available for testing";
24}
25else {
26  plan tests => 7;
27}
28
29ok $b, "created EU::CB object";
30
31ok $b->have_cplusplus, "have_cplusplus";
32
33$source_file = File::Spec->catfile('t', 'cplust.cc');
34{
35  open my $FH, "> $source_file" or die "Can't create $source_file: $!";
36  print $FH "class Bogus { public: int boot_cplust() { return 1; } };\n";
37  close $FH;
38}
39ok -e $source_file, "source file '$source_file' created";
40
41$object_file = $b->object_file($source_file);
42ok 1;
43
44is $object_file, $b->compile(source => $source_file, 'C++' => 1);
45
46$lib_file = $b->lib_file($object_file);
47ok 1;
48
49my ($lib, @temps) = $b->link(objects => $object_file,
50                             module_name => 'cplust');
51$lib =~ tr/"'//d;
52is $lib_file, $lib;
53
54for ($source_file, $object_file, $lib_file) {
55  tr/"'//d;
56  1 while unlink;
57}
58
59if ($^O eq 'VMS') {
60   1 while unlink 'CPLUST.LIS';
61   1 while unlink 'CPLUST.OPT';
62}
63
64