This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Restore "Add new hashing and "hash with state" infrastructure"
[perl5.git] / t / porting / globvar.t
CommitLineData
1f7ae1be
NC
1#!perl -w
2
3use TestInit qw(T);
4use strict;
5use Config;
6
3d7c117d 7require './t/test.pl';
1f7ae1be
NC
8
9skip_all("Code to read symbols not ported to $^O")
b63f993a 10 if $^O eq 'VMS' or $^O eq 'MSWin32';
1f7ae1be
NC
11
12# Not investigated *why* we don't export these, but we don't, and we've not
13# received any bug reports about it causing problems:
14my %skip = map { ("PL_$_", 1) }
15 qw(
16 DBcv bitcount cshname force_link_funcs generation lastgotoprobe
c52cb817 17 mod_latin1_uc modcount no_symref_sv uudmap
9d5e3f1a 18 watchaddr watchok warn_uninit_sv hash_chars
1f7ae1be
NC
19 );
20
6a5b4183 21$skip{PL_hash_rand_bits}= $skip{PL_hash_rand_bits_enabled}= 1; # we can be compiled without these, so skip testing them
c98d1975 22$skip{PL_warn_locale}= 1; # we can be compiled without locales, so skip testing them
6a5b4183
YO
23
24
1f7ae1be
NC
25my $trial = "nm globals$Config{_o} 2>&1";
26my $yes = `$trial`;
27
28skip_all("Could not run `$trial`") if $?;
29
30my $defined = qr/^[0-9a-fA-F]{8,16}\s+[^Uu]\s+_?/m;
31
32skip_all("Could not spot definition of PL_Yes in output of `$trial`")
33 unless $yes =~ /${defined}PL_Yes/m;
34
35my %exported;
36open my $fh, '-|', $^X, '-Ilib', './makedef.pl', 'PLATFORM=test'
37 or die "Can't run makedef.pl";
38
39while (<$fh>) {
40 next unless /^PL_/;
41 chomp;
42 ++$exported{$_};
43}
44
45close $fh or die "Problem running makedef.pl";
46
47my %unexported;
48
49foreach my $file (map {$_ . $Config{_o}} qw(globals regcomp)) {
50 open $fh, '-|', 'nm', $file
51 or die "Can't run nm $file";
52
53 while (<$fh>) {
54 next unless /$defined(PL_\S+)/;
55 if (delete $exported{$1}) {
56 note("Seen definition of $1");
57 next;
58 }
59 ++$unexported{$1};
60 }
61 close $fh or die "Problem running nm $file";
62}
63
85272d31 64unless ($Config{d_double_has_inf}) {
118e3066 65 $skip{PL_inf}++;
85272d31
JH
66}
67unless ($Config{d_double_has_nan}) {
118e3066
JH
68 $skip{PL_nan}++;
69}
70
6a5b4183
YO
71foreach (sort keys %exported) {
72 SKIP: {
73 skip("We dont't export '$_' (Perl not built with this enabled?)",1) if $skip{$_};
74 fail("Attempting to export '$_' which is never defined");
75 }
76}
1f7ae1be
NC
77
78foreach (sort keys %unexported) {
79 SKIP: {
6a5b4183
YO
80 skip("We don't export '$_'", 1) if $skip{$_};
81 fail("'$_' is defined, but we do not export it");
1f7ae1be
NC
82 }
83}
84
85done_testing();