xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/t/comp/package.t (revision 0:68f95e015346)
1#!./perl
2
3print "1..8\n";
4
5$blurfl = 123;
6$foo = 3;
7
8package xyz;
9
10$bar = 4;
11
12{
13    package ABC;
14    $blurfl = 5;
15    $main'a = $'b;
16}
17
18$ABC'dyick = 6;
19
20$xyz = 2;
21
22$main = join(':', sort(keys %main::));
23$xyz = join(':', sort(keys %xyz::));
24$ABC = join(':', sort(keys %ABC::));
25
26if ('a' lt 'A') {
27    print $xyz eq 'bar:main:xyz:ABC' ? "ok 1\n" : "not ok 1 '$xyz'\n";
28} else {
29    print $xyz eq 'ABC:bar:main:xyz' ? "ok 1\n" : "not ok 1 '$xyz'\n";
30}
31print $ABC eq 'blurfl:dyick' ? "ok 2\n" : "not ok 2 '$ABC'\n";
32print $main'blurfl == 123 ? "ok 3\n" : "not ok 3\n";
33
34package ABC;
35
36print $blurfl == 5 ? "ok 4\n" : "not ok 4\n";
37eval 'print $blurfl == 5 ? "ok 5\n" : "not ok 5\n";';
38eval 'package main; print $blurfl == 123 ? "ok 6\n" : "not ok 6\n";';
39print $blurfl == 5 ? "ok 7\n" : "not ok 7\n";
40
41package main;
42
43sub c { caller(0) }
44
45sub foo {
46   my $s = shift;
47   if ($s) {
48	package PQR;
49	main::c();
50   }
51}
52
53print((foo(1))[0] eq 'PQR' ? "ok 8\n" : "not ok 8\n");
54