This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Move all the xxxpvs() macros to handy.h.
[perl5.git] / ext / B / t / stash.t
1 #!./perl
2
3 BEGIN {
4     if ($ENV{PERL_CORE}){
5         chdir('t') if -d 't';
6         if ($^O eq 'MacOS') {
7             @INC = qw(: ::lib ::macos:lib);
8         } else {
9             @INC = '.';
10             push @INC, '../lib';
11         }
12     } else {
13         unshift @INC, 't';
14     }
15     require Config;
16     if (($Config::Config{'extensions'} !~ /\bB\b/) ){
17         print "1..0 # Skip -- Perl configured without B module\n";
18         exit 0;
19     }
20 }
21
22 $|  = 1;
23 use warnings;
24 use strict;
25 use Config;
26
27 print "1..1\n";
28
29 my $test = 1;
30
31 sub ok { print "ok $test\n"; $test++ }
32
33
34 my $got;
35 my $Is_VMS = $^O eq 'VMS';
36 my $Is_MacOS = $^O eq 'MacOS';
37
38 my $path = join " ", map { qq["-I$_"] } @INC;
39 $path = '"-I../lib" "-Iperl_root:[lib]"' if $Is_VMS;   # gets too long otherwise
40 my $redir = $Is_MacOS ? "" : "2>&1";
41
42 chomp($got = `$^X $path "-MB::Stash" "-Mwarnings" -e1`);
43
44 $got =~ s/-u//g;
45
46 print "# got = $got\n";
47
48 my @got = map { s/^\S+ //; $_ }
49               sort { $a cmp $b }
50                    map { lc($_) . " " . $_ }
51                        split /,/, $got;
52
53 print "# (after sorting)\n";
54 print "# got = @got\n";
55
56 @got = grep { ! /^(PerlIO|open)(?:::\w+)?$/ } @got;
57
58 print "# (after perlio censorings)\n";
59 print "# got = @got\n";
60
61 @got = grep { ! /^Win32$/                     } @got  if $^O eq 'MSWin32';
62 @got = grep { ! /^NetWare$/                   } @got  if $^O eq 'NetWare';
63 @got = grep { ! /^(Cwd|File|File::Copy|OS2)$/ } @got  if $^O eq 'os2';
64 @got = grep { ! /^(Cwd|Cygwin)$/              } @got  if $^O eq 'cygwin';
65
66 if ($Is_VMS) {
67     @got = grep { ! /^File(?:::Copy)?$/    } @got;
68     @got = grep { ! /^VMS(?:::Filespec)?$/ } @got;
69     @got = grep { ! /^vmsish$/             } @got;
70      # Socket is optional/compiler version dependent
71     @got = grep { ! /^Socket$/             } @got;
72 }
73
74 print "# (after platform censorings)\n";
75 print "# got = @got\n";
76
77 $got = "@got";
78
79 my $expected = "attributes Carp Carp::Heavy DB Internals main Regexp utf8 version warnings";
80
81 if ($] < 5.009) {
82     $expected =~ s/version //;
83     $expected =~ s/DB/DB Exporter Exporter::Heavy/;
84 }
85
86 {
87     no strict 'vars';
88     use vars '$OS2::is_aout';
89 }
90
91 if ((($Config{static_ext} eq ' ') || ($Config{static_ext} eq ''))
92     && !($^O eq 'os2' and $OS2::is_aout)
93         ) {
94     print "# got [$got]\n# vs.\n# expected [$expected]\nnot " if $got ne $expected;
95     ok;
96 } else {
97     print "ok $test # skipped: one or more static extensions\n"; $test++;
98 }
99