threads::shared::queue and semaphore become Thread::Semaphore
[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
45like(Config::config_sh(), qr/cc='$Config{cc}'/, "config_sh");
46
47my $out = tie *STDOUT, 'FakeOut';
48
49Config::config_vars('cc');
50my $out1 = $$out;
51$out->clear;
52
53Config::config_vars('d_bork');
54my $out2 = $$out;
55$out->clear;
56
57untie *STDOUT;
58
59like($out1, qr/^cc='$Config{cc}';/, "config_vars cc");
60like($out2, qr/^d_bork='UNKNOWN';/, "config_vars d_bork is UNKNOWN");
61
62# Read-only.
63
7956ade2 64undef $@;
41aba5b7 65eval { $Config{d_bork} = 'borkbork' };
66like($@, qr/Config is read-only/, "no STORE");
67
7956ade2 68ok(!exists $Config{d_bork}, "still no d_bork");
69
70undef $@;
41aba5b7 71eval { delete $Config{d_fork} };
72like($@, qr/Config is read-only/, "no DELETE");
73
7956ade2 74ok( exists $Config{d_fork}, "still d_fork");
75
76undef $@;
41aba5b7 77eval { %Config = () };
78like($@, qr/Config is read-only/, "no CLEAR");
79
7956ade2 80ok( exists $Config{d_fork}, "still d_fork");
81
41aba5b7 82package FakeOut;
83
84sub TIEHANDLE {
85 bless(\(my $text), $_[0]);
86}
87
88sub clear {
89 ${ $_[0] } = '';
90}
91
41aba5b7 92sub PRINT {
93 my $self = shift;
7956ade2 94 $$self .= join('', @_);
41aba5b7 95}
96