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');
79 Config::config_vars('d_bork');
83 Config::config_vars('PERL_API_.*');
87 Config::config_vars(':PERL_API_.*:');
91 Config::config_vars(':PERL_API_REVISION:');
95 Config::config_vars('?flags');
100 like($out1, qr/^cc='\Q$Config{cc}\E';/, "config_vars cc");
101 like($out2, qr/^d_bork='UNKNOWN';/, "config_vars d_bork is UNKNOWN");
103 is(3, scalar split(/\n/, $out3), "3 PERL_API vars found");
104 my @api = $out3 =~ /^PERL_API_(\w+)=(.*);/mg;
105 is("'5'", $api[1], "1st is 5");
106 is("'9'", $api[5], "2nd is 9");
107 is("'1'", $api[3], "3rd is 1");
108 @api = split(/ /, $out4);
109 is(3, @api, "trailing colon puts 3 terms on same line");
110 unlike($out4, qr/=/, "leading colon suppresses param names");
111 is("'5'", $api[0], "revision is 5");
112 is("'9'", $api[2], "version is 9");
113 is("'1'", $api[1], "subversion is 1");
115 is("'5' ", $out5, "leading and trailing colons return just the value");
117 like($out6, qr/\bnot\s+found\b/, "config_vars with invalid regexp");
122 eval { $Config{d_bork} = 'borkbork' };
123 like($@, qr/Config is read-only/, "no STORE");
125 ok(!exists $Config{d_bork}, "still no d_bork");
128 eval { delete $Config{d_fork} };
129 like($@, qr/Config is read-only/, "no DELETE");
131 ok( exists $Config{d_fork}, "still d_fork");
134 eval { %Config = () };
135 like($@, qr/Config is read-only/, "no CLEAR");
137 ok( exists $Config{d_fork}, "still d_fork");
143 bless(\(my $text), $_[0]);
152 $$self .= join('', @_);
156 # Signal-related variables
157 # (this is actually a regression test for Configure.)
159 is($Config{sig_num_init} =~ tr/,/,/, $Config{sig_size}, "sig_num_init size");
160 is($Config{sig_name_init} =~ tr/,/,/, $Config{sig_size}, "sig_name_init size");
162 # Test the troublesome virtual stuff
163 foreach my $pain (qw(byteorder)) {
164 # No config var is named with anything that is a regexp metachar"
165 my @result = Config::config_re($pain);
166 is (scalar @result, 1, "single result for config_re('$pain')");
167 like ($result[0], qr/^$pain=(['"])$Config{$pain}\1$/, # grr '
168 "which is the expected result for $pain");