| [3181] | 1 | #!./perl -w
|
|---|
| 2 |
|
|---|
| 3 | BEGIN {
|
|---|
| 4 | chdir 't' if -d 't';
|
|---|
| 5 | @INC = '../lib';
|
|---|
| 6 | require "./test.pl";
|
|---|
| 7 |
|
|---|
| 8 | plan ('no_plan');
|
|---|
| 9 |
|
|---|
| 10 | use_ok('Config');
|
|---|
| 11 | }
|
|---|
| 12 |
|
|---|
| 13 | use strict;
|
|---|
| 14 |
|
|---|
| 15 | # Some (safe?) bets.
|
|---|
| 16 |
|
|---|
| 17 | ok(keys %Config > 500, "Config has more than 500 entries");
|
|---|
| 18 |
|
|---|
| 19 | my ($first) = Config::config_sh() =~ /^(\S+)=/m;
|
|---|
| 20 | die "Can't find first entry in Config::config_sh()" unless defined $first;
|
|---|
| 21 | print "# First entry is '$first'\n";
|
|---|
| 22 |
|
|---|
| 23 | # It happens that the we know what the first key should be. This is somewhat
|
|---|
| 24 | # cheating, but there was briefly a bug where the key got a bonus newline.
|
|---|
| 25 | my ($first_each) = each %Config;
|
|---|
| 26 | is($first_each, $first, "First key from each is correct");
|
|---|
| 27 | ok(exists($Config{$first_each}), "First key exists");
|
|---|
| 28 | ok(!exists($Config{"\n$first"}),
|
|---|
| 29 | "Check that first key with prepended newline isn't falsely existing");
|
|---|
| 30 |
|
|---|
| 31 | is($Config{PERL_REVISION}, 5, "PERL_REVISION is 5");
|
|---|
| 32 |
|
|---|
| 33 | # Check that old config variable names are aliased to their new ones.
|
|---|
| 34 | my %grandfathers = ( PERL_VERSION => 'PATCHLEVEL',
|
|---|
| 35 | PERL_SUBVERSION => 'SUBVERSION',
|
|---|
| 36 | PERL_CONFIG_SH => 'CONFIG'
|
|---|
| 37 | );
|
|---|
| 38 | while( my($new, $old) = each %grandfathers ) {
|
|---|
| 39 | isnt($Config{$new}, undef, "$new is defined");
|
|---|
| 40 | is($Config{$new}, $Config{$old}, "$new is aliased to $old");
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | ok( exists $Config{cc}, "has cc");
|
|---|
| 44 |
|
|---|
| 45 | ok( exists $Config{ccflags}, "has ccflags");
|
|---|
| 46 |
|
|---|
| 47 | ok(!exists $Config{python}, "has no python");
|
|---|
| 48 |
|
|---|
| 49 | ok( exists $Config{d_fork}, "has d_fork");
|
|---|
| 50 |
|
|---|
| 51 | ok(!exists $Config{d_bork}, "has no d_bork");
|
|---|
| 52 |
|
|---|
| 53 | like($Config{ivsize}, qr/^(4|8)$/, "ivsize is 4 or 8 (it is $Config{ivsize})");
|
|---|
| 54 |
|
|---|
| 55 | # byteorder is virtual, but it has rules.
|
|---|
| 56 |
|
|---|
| 57 | like($Config{byteorder}, qr/^(1234|4321|12345678|87654321)$/,
|
|---|
| 58 | "byteorder is 1234 or 4321 or 12345678 or 87654321 "
|
|---|
| 59 | . "(it is $Config{byteorder})");
|
|---|
| 60 |
|
|---|
| 61 | is(length $Config{byteorder}, $Config{ivsize},
|
|---|
| 62 | "byteorder is as long as ivsize (which is $Config{ivsize})");
|
|---|
| 63 |
|
|---|
| 64 | # ccflags_nolargefiles is virtual, too.
|
|---|
| 65 |
|
|---|
| 66 | ok(exists $Config{ccflags_nolargefiles}, "has ccflags_nolargefiles");
|
|---|
| 67 |
|
|---|
| 68 | # Utility functions.
|
|---|
| 69 |
|
|---|
| 70 | {
|
|---|
| 71 | # make sure we can export what we say we can export.
|
|---|
| 72 | package Foo;
|
|---|
| 73 | my @exports = qw(myconfig config_sh config_vars config_re);
|
|---|
| 74 | Config->import(@exports);
|
|---|
| 75 | foreach my $func (@exports) {
|
|---|
| 76 | ::ok( __PACKAGE__->can($func), "$func exported" );
|
|---|
| 77 | }
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | like(Config::myconfig(), qr/osname=\Q$Config{osname}\E/, "myconfig");
|
|---|
| 81 | like(Config::config_sh(), qr/osname='\Q$Config{osname}\E'/, "config_sh");
|
|---|
| 82 | like(Config::config_sh(), qr/byteorder='[1-8]+'/,
|
|---|
| 83 | "config_sh has a valid byteorder");
|
|---|
| 84 | foreach my $line (Config::config_re('c.*')) {
|
|---|
| 85 | like($line, qr/^c.*?=.*$/, 'config_re' );
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | my $out = tie *STDOUT, 'FakeOut';
|
|---|
| 89 |
|
|---|
| 90 | Config::config_vars('cc'); # non-regex test of essential cfg-var
|
|---|
| 91 | my $out1 = $$out;
|
|---|
| 92 | $out->clear;
|
|---|
| 93 |
|
|---|
| 94 | Config::config_vars('d_bork'); # non-regex, non-existent cfg-var
|
|---|
| 95 | my $out2 = $$out;
|
|---|
| 96 | $out->clear;
|
|---|
| 97 |
|
|---|
| 98 | Config::config_vars('PERL_API_.*'); # regex, tagged multi-line answer
|
|---|
| 99 | my $out3 = $$out;
|
|---|
| 100 | $out->clear;
|
|---|
| 101 |
|
|---|
| 102 | Config::config_vars('PERL_API_.*:'); # regex, tagged single-line answer
|
|---|
| 103 | my $out4 = $$out;
|
|---|
| 104 | $out->clear;
|
|---|
| 105 |
|
|---|
| 106 | Config::config_vars(':PERL_API_.*:'); # regex, non-tagged single-line answer
|
|---|
| 107 | my $out5 = $$out;
|
|---|
| 108 | $out->clear;
|
|---|
| 109 |
|
|---|
| 110 | Config::config_vars(':PERL_API_.*'); # regex, non-tagged multi-line answer
|
|---|
| 111 | my $out6 = $$out;
|
|---|
| 112 | $out->clear;
|
|---|
| 113 |
|
|---|
| 114 | Config::config_vars('PERL_API_REVISION.*:'); # regex, tagged
|
|---|
| 115 | my $out7 = $$out;
|
|---|
| 116 | $out->clear;
|
|---|
| 117 |
|
|---|
| 118 | # regex, non-tagged multi-line answer
|
|---|
| 119 | Config::config_vars(':PERL_API_REVISION.*');
|
|---|
| 120 | my $out8 = $$out;
|
|---|
| |
|---|