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, module_name => 'cplust');
47ok 1;
48
49my ($lib, @temps) = $b->link(objects => $object_file,
50                             module_name => 'cplust');
51$lib =~ tr/"'//d;
52$_ = File::Spec->rel2abs($_) for $lib_file, $lib;
53is $lib_file, $lib;
54
55for ($source_file, $object_file, $lib_file) {
56  tr/"'//d;
57  1 while unlink;
58}
59
60if ($^O eq 'VMS') {
61   1 while unlink 'CPLUST.LIS';
62   1 while unlink 'CPLUST.OPT';
63}
64
65