15 ok(keys %Config > 500, "Config has more than 500 entries");
19 is($Config{PERL_REVISION}, 5, "PERL_REVISION is 5");
21 # Check that old config variable names are aliased to their new ones.
22 my %grandfathers = ( PERL_VERSION => 'PATCHLEVEL',
23 PERL_SUBVERSION => 'SUBVERSION',
24 PERL_CONFIG_SH => 'CONFIG'
26 while( my($new, $old) = each %grandfathers ) {
27 isnt($Config{$new}, undef, "$new is defined");
28 is($Config{$new}, $Config{$old}, "$new is aliased to $old");
31 ok( exists $Config{cc}, "has cc");
33 ok( exists $Config{ccflags}, "has ccflags");
35 ok(!exists $Config{python}, "has no python");
37 ok( exists $Config{d_fork}, "has d_fork");
39 ok(!exists $Config{d_bork}, "has no d_bork");
41 like($Config{ivsize}, qr/^(4|8)$/, "ivsize is 4 or 8 (it is $Config{ivsize})");
43 # byteorder is virtual, but it has rules.
45 like($Config{byteorder}, qr/^(1234|4321|12345678|87654321)$/, "byteorder is 1234 or 4321 or 12345678 or 87654321 (it is $Config{byteorder})");
47 is(length $Config{byteorder}, $Config{ivsize}, "byteorder is as long as ivsize (which is $Config{ivsize})");
49 # ccflags_nolargefiles is virtual, too.
51 ok(exists $Config{ccflags_nolargefiles}, "has ccflags_nolargefiles");
56 # make sure we can export what we say we can export.
58 my @exports = qw(myconfig config_sh config_vars config_re);
59 Config->import(@exports);
60 foreach my $func (@exports) {
61 ::ok( __PACKAGE__->can($func), "$func exported" );
65 like(Config::myconfig(), qr/osname=\Q$Config{osname}\E/, "myconfig");
66 like(Config::config_sh(), qr/osname='\Q$Config{osname}\E'/, "config_sh");
67 like(Config::config_sh(), qr/byteorder='[1-8]+'/,
68 "config_sh has a valid byteorder");
69 foreach my $line (Config::config_re('c.*')) {
70 like($line, qr/^c.*?=.*$/, 'config_re' );
73 my $out = tie *STDOUT, 'FakeOut';
75 Config::config_vars('cc'); # non-regex test of essential cfg-var
79 Config::config_vars('d_bork'); # non-regex, non-existent cfg-var
83 Config::config_vars('PERL_API_.*'); # regex, tagged multi-line answer
87 Config::config_vars('PERL_API_.*:'); # regex, tagged single-line answer
91 Config::config_vars(':PERL_API_.*:'); # regex, non-tagged single-line answer
95 Config::config_vars(':PERL_API_.*'); # regex, non-tagged multi-line answer
99 Config::config_vars('PERL_API_REVISION.*:'); # regex, tagged
103 Config::config_vars(':PERL_API_REVISION.*'); # regex, non-tagged multi-line answer
107 Config::config_vars('PERL_EXPENSIVE_.*:'); # non-matching regex
111 Config::config_vars('?flags'); # bogus regex, no explicit warning !
117 like($out1, qr/^cc='\Q$Config{cc}\E';/, "found config_var cc");
118 like($out2, qr/^d_bork='UNKNOWN';/, "config_var d_bork is UNKNOWN");
120 # test for leading, trailing colon effects
121 is(scalar split(/;\n/, $out3), 3, "3 lines found");
122 is(scalar split(/;\n/, $out6), 3, "3 lines found");
124 is($out4 =~ /(;\n)/s, '', "trailing colon gives 1-line response: $out4");
125 is($out5 =~ /(;\n)/s, '', "trailing colon gives 1-line response: $out5");
127 is(scalar split(/=/, $out3), 4, "found 'tag='");
128 is(scalar split(/=/, $out4), 4, "found 'tag='");
132 my @rev = @Config{qw(PERL_API_REVISION PERL_API_VERSION PERL_API_SUBVERSION)};
134 print ("# test tagged responses, multi-line and single-line\n");
135 foreach $api ($out3, $out4) {
136 @api = $api =~ /PERL_API_(\w+)=(.*?)(?:;\n|\s)/mg;
137 is($api[0], "REVISION", "REVISION tag");
138 is($api[4], "VERSION", "VERSION tag");
139 is($api[2], "SUBVERSION", "SUBVERSION tag");
140 is($api[1], "'$rev[0]'", "REVISION is $rev[0]");
141 is($api[5], "'$rev[1]'", "VERSION is $rev[1]");
142 is($api[3], "'$rev[2]'", "SUBVERSION is $rev[2]");
145 print("# test non-tagged responses, multi-line and single-line\n");
146 foreach $api ($out5, $out6) {
147 @api = split /(?: |;\n)/, $api;
148 is($api[0], "'$rev[0]'", "revision is $rev[0]");
149 is($api[2], "'$rev[1]'", "version is $rev[1]");
150 is($api[1], "'$rev[2]'", "subversion is $rev[2]");
153 # compare to each other, the outputs for trailing, leading colon
155 is("$out7;\n", "PERL_API_REVISION=$out8", "got expected diffs");
157 like($out9, qr/\bnot\s+found\b/, "$out9 - perl is FREE !");
158 like($out10, qr/\bnot\s+found\b/, "config_vars with invalid regexp");
163 eval { $Config{d_bork} = 'borkbork' };
164 like($@, qr/Config is read-only/, "no STORE");
166 ok(!exists $Config{d_bork}, "still no d_bork");
169 eval { delete $Config{d_fork} };
170 like($@, qr/Config is read-only/, "no DELETE");
172 ok( exists $Config{d_fork}, "still d_fork");
175 eval { %Config = () };
176 like($@, qr/Config is read-only/, "no CLEAR");
178 ok( exists $Config{d_fork}, "still d_fork");
184 bless(\(my $text), $_[0]);
193 $$self .= join('', @_);
197 # Signal-related variables
198 # (this is actually a regression test for Configure.)
200 is($Config{sig_num_init} =~ tr/,/,/, $Config{sig_size}, "sig_num_init size");
201 is($Config{sig_name_init} =~ tr/,/,/, $Config{sig_size}, "sig_name_init size");
203 # Test the troublesome virtual stuff
204 foreach my $pain (qw(byteorder)) {
205 # No config var is named with anything that is a regexp metachar"
206 my @result = Config::config_re($pain);
207 is (scalar @result, 1, "single result for config_re('$pain')");
208 like ($result[0], qr/^$pain=(['"])$Config{$pain}\1$/, # grr '
209 "which is the expected result for $pain");