posixify getppid on linux-multithread
[p5sagit/p5-mst-13.2.git] / lib / Config.t
CommitLineData
41aba5b7 1BEGIN {
2 chdir 't' if -d 't';
3 @INC = '../lib';
4 require "./test.pl";
5}
6
7956ade2 7plan tests => 23;
41aba5b7 8
9use_ok('Config');
10
11# Some (safe?) bets.
12
484fdf61 13ok(keys %Config > 500, "Config has more than 500 entries");
41aba5b7 14
15ok(each %Config);
16
17is($Config{PERL_REVISION}, 5, "PERL_REVISION is 5");
18
41aba5b7 19ok( exists $Config{cc}, "has cc");
20
21ok( exists $Config{ccflags}, "has ccflags");
22
23ok(!exists $Config{python}, "has no python");
24
25ok( exists $Config{d_fork}, "has d_fork");
26
27ok(!exists $Config{d_bork}, "has no d_bork");
28
7956ade2 29like($Config{ivsize}, qr/^(4|8)$/, "ivsize is 4 or 8 (it is $Config{ivsize})");
30
41aba5b7 31# byteorder is virtual, but it has rules.
32
7956ade2 33like($Config{byteorder}, qr/^(1234|4321|12345678|87654321)$/, "byteorder is 1234 or 4321 or 12345678 or 87654321 (it is $Config{byteorder})");
41aba5b7 34
7956ade2 35is(length $Config{byteorder}, $Config{ivsize}, "byteorder is as long as ivsize (which is $Config{ivsize})");
41aba5b7 36
37# ccflags_nolargefiles is virtual, too.
38
39ok(exists $Config{ccflags_nolargefiles}, "has ccflags_nolargefiles");
40
41# Utility functions.
42
43like(Config::myconfig(), qr/cc='$Config{cc}'/, "myconfig");
44
6664971e 45SKIP: {
46 skip "cc is tied in $^O", 1 if $^O eq 'MacOS';
47 like(Config::config_sh(), qr/cc='$Config{cc}'/, "config_sh");
48}
41aba5b7 49
50my $out = tie *STDOUT, 'FakeOut';
51
52Config::config_vars('cc');
53my $out1 = $$out;
54$out->clear;
55
56Config::config_vars('d_bork');
57my $out2 = $$out;
58$out->clear;
59
60untie *STDOUT;
61
62like($out1, qr/^cc='$Config{cc}';/, "config_vars cc");
63like($out2, qr/^d_bork='UNKNOWN';/, "config_vars d_bork is UNKNOWN");
64
65# Read-only.
66
7956ade2 67undef $@;
41aba5b7 68eval { $Config{d_bork} = 'borkbork' };
69like($@, qr/Config is read-only/, "no STORE");
70
7956ade2 71ok(!exists $Config{d_bork}, "still no d_bork");
72
73undef $@;
41aba5b7 74eval { delete $Config{d_fork} };
75like($@, qr/Config is read-only/, "no DELETE");
76
7956ade2 77ok( exists $Config{d_fork}, "still d_fork");
78
79undef $@;
41aba5b7 80eval { %Config = () };
81like($@, qr/Config is read-only/, "no CLEAR");
82
7956ade2 83ok( exists $Config{d_fork}, "still d_fork");
84
41aba5b7 85package FakeOut;
86
87sub TIEHANDLE {
88 bless(\(my $text), $_[0]);
89}
90
91sub clear {
92 ${ $_[0] } = '';
93}
94
41aba5b7 95sub PRINT {
96 my $self = shift;
7956ade2 97 $$self .= join('', @_);
41aba5b7 98}
99