X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FConfig.t;h=6e4b47cfa86578ec6ec0c20504e99782ef06997a;hb=cc83745da206d409d7227df077f422fd9ecbe680;hp=09f3cf122451f50df307381842d18e3cafd0c53d;hpb=41aba5b7c932fca7d8ac17a1d4cc2e43239a475c;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/Config.t b/lib/Config.t index 09f3cf1..6e4b47c 100644 --- a/lib/Config.t +++ b/lib/Config.t @@ -1,22 +1,32 @@ +#!./perl + BEGIN { chdir 't' if -d 't'; @INC = '../lib'; require "./test.pl"; } -plan tests => 20; +plan tests => 36; use_ok('Config'); # Some (safe?) bets. -ok(keys %Config > 900, "Config has more than 900 entries"); +ok(keys %Config > 500, "Config has more than 500 entries"); ok(each %Config); is($Config{PERL_REVISION}, 5, "PERL_REVISION is 5"); -like($Config{ivsize}, qr/^(4|8)$/, "ivsize is 4 or 8"); +# Check that old config variable names are aliased to their new ones. +my %grandfathers = ( PERL_VERSION => 'PATCHLEVEL', + PERL_SUBVERSION => 'SUBVERSION', + PERL_CONFIG_SH => 'CONFIG' + ); +while( my($new, $old) = each %grandfathers ) { + isnt($Config{$new}, undef, "$new is defined"); + is($Config{$new}, $Config{$old}, "$new is aliased to $old"); +} ok( exists $Config{cc}, "has cc"); @@ -28,11 +38,13 @@ ok( exists $Config{d_fork}, "has d_fork"); ok(!exists $Config{d_bork}, "has no d_bork"); +like($Config{ivsize}, qr/^(4|8)$/, "ivsize is 4 or 8 (it is $Config{ivsize})"); + # byteorder is virtual, but it has rules. -like($Config{byteorder}, qr/^(1234|4321|12345678|87654321)$/, "byteorder is 1234 or 4321 or 12345678 or 87654321"); +like($Config{byteorder}, qr/^(1234|4321|12345678|87654321)$/, "byteorder is 1234 or 4321 or 12345678 or 87654321 (it is $Config{byteorder})"); -is(length $Config{byteorder}, $Config{ivsize}, "byteorder is as long as ivsize"); +is(length $Config{byteorder}, $Config{ivsize}, "byteorder is as long as ivsize (which is $Config{ivsize})"); # ccflags_nolargefiles is virtual, too. @@ -40,9 +52,20 @@ ok(exists $Config{ccflags_nolargefiles}, "has ccflags_nolargefiles"); # Utility functions. -like(Config::myconfig(), qr/cc='$Config{cc}'/, "myconfig"); +{ + # make sure we can export what we say we can export. + package Foo; + my @exports = qw(myconfig config_sh config_vars config_re); + Config->import(@exports); + foreach my $func (@exports) { + ::ok( __PACKAGE__->can($func), "$func exported" ); + } +} -like(Config::config_sh(), qr/cc='$Config{cc}'/, "config_sh"); +like(Config::myconfig(), qr/osname=\Q$Config{osname}\E/, "myconfig"); +like(Config::config_sh(), qr/osname='\Q$Config{osname}\E'/, "config_sh"); +like(join("\n", Config::config_re('c.*')), + qr/^c.*?=/, 'config_re' ); my $out = tie *STDOUT, 'FakeOut'; @@ -56,38 +79,48 @@ $out->clear; untie *STDOUT; -like($out1, qr/^cc='$Config{cc}';/, "config_vars cc"); +like($out1, qr/^cc='\Q$Config{cc}\E';/, "config_vars cc"); like($out2, qr/^d_bork='UNKNOWN';/, "config_vars d_bork is UNKNOWN"); # Read-only. +undef $@; eval { $Config{d_bork} = 'borkbork' }; like($@, qr/Config is read-only/, "no STORE"); +ok(!exists $Config{d_bork}, "still no d_bork"); + +undef $@; eval { delete $Config{d_fork} }; like($@, qr/Config is read-only/, "no DELETE"); +ok( exists $Config{d_fork}, "still d_fork"); + +undef $@; eval { %Config = () }; like($@, qr/Config is read-only/, "no CLEAR"); -package FakeOut; +ok( exists $Config{d_fork}, "still d_fork"); -sub TIEHANDLE { - bless(\(my $text), $_[0]); -} +{ + package FakeOut; -sub clear { - ${ $_[0] } = ''; -} + sub TIEHANDLE { + bless(\(my $text), $_[0]); + } -# remove the bell character -sub scrub { - ${ $_[0] } =~ tr/\a//d; -} + sub clear { + ${ $_[0] } = ''; + } -# must shift off self -sub PRINT { - my $self = shift; - ($$self .= join('', @_)) =~ s/\s+/./gm; + sub PRINT { + my $self = shift; + $$self .= join('', @_); + } } +# Signal-related variables +# (this is actually a regression test for Configure.) + +is($Config{sig_num_init} =~ tr/,/,/, $Config{sig_size}, "sig_num_init size"); +is($Config{sig_name_init} =~ tr/,/,/, $Config{sig_size}, "sig_name_init size");