+ Docs and test
[p5sagit/p5-mst-13.2.git] / lib / Pod / t / Functions.t
1 #!perl
2
3 BEGIN {
4         chdir 't' if -d 't';
5         @INC = '../lib';
6
7 }
8
9 use File::Basename;
10 use File::Spec;
11
12 use Test::More;
13 plan tests => 9;
14
15
16 use_ok( 'Pod::Functions' );
17
18 # How do you test exported vars?
19 my( $pkg_ref, $exp_ref ) = ( \%Pod::Functions::Kinds, \%Kinds );
20 is( $pkg_ref, $exp_ref, '%Pod::Functions::Kinds exported' );
21
22 ( $pkg_ref, $exp_ref ) = ( \%Pod::Functions::Type, \%Type );
23 is( $pkg_ref, $exp_ref, '%Pod::Functions::Type exported' );
24
25 ( $pkg_ref, $exp_ref ) = ( \%Pod::Functions::Flavor, \%Flavor );
26 is( $pkg_ref, $exp_ref, '%Pod::Functions::Flavor exported' );
27
28 ( $pkg_ref, $exp_ref ) = ( \%Pod::Functions::Type_Description, 
29                            \%Type_Description );
30 is( $pkg_ref, $exp_ref, '%Pod::Functions::Type_Description exported' );
31
32 ( $pkg_ref, $exp_ref ) = ( \@Pod::Functions::Type_Order, \@Type_Order );
33 is( $pkg_ref, $exp_ref, '@Pod::Functions::Type_Order exported' );
34
35 # Check @Type_Order
36 my @catagories = qw(
37     String  Regexp Math ARRAY     LIST    HASH    I/O
38     Binary  File   Flow Namespace Misc    Process Modules
39     Objects Socket SysV User      Network Time
40 );
41
42 ok( eq_array( \@Type_Order, \@catagories ),
43     '@Type_Order' );
44
45 my @cat_keys = grep exists $Type_Description{ $_ } => @Type_Order;
46
47 ok( eq_array( \@cat_keys, \@catagories ),
48     'keys() %Type_Description' );
49
50 my( undef, $path ) = fileparse( $0 );
51 my $pod_functions = File::Spec->catfile( 
52     $path, File::Spec->updir, 'Functions.pm' );
53
54 SKIP: {
55         my $test_out = do { local $/; <DATA> }; 
56         
57         skip( "Can't fork '$^X': $!", 1) 
58             unless open my $fh, "$^X $pod_functions |";
59         my $fake_out = do { local $/; <$fh> };
60         while ( <$fh> ) { $fake_out .= $_ }
61         skip( "Pipe error: $!", 1)
62             unless close $fh;
63
64     is( $fake_out, $test_out, 'run as plain program' );
65 }
66
67 =head1 NAME
68
69 Functions.t - Test Pod::Functions
70
71 =head1 AUTHOR
72
73 20011229 Abe Timmerman <abe@ztreet.demon.nl>
74
75 =cut
76
77 __DATA__
78
79 Functions for SCALARs or strings:
80      chomp, chop, chr, crypt, hex, index, lc, lcfirst, length,
81      oct, ord, pack, q/STRING/, qq/STRING/, reverse, rindex,
82      sprintf, substr, tr///, uc, ucfirst, y///
83
84 Regular expressions and pattern matching:
85      m//, pos, qr/PATTERN/, quotemeta, s///, split, study
86
87 Numeric functions:
88      abs, atan2, cos, exp, hex, int, log, oct, rand, sin, sqrt,
89      srand
90
91 Functions for real @ARRAYs:
92      pop, push, shift, splice, unshift
93
94 Functions for list data:
95      grep, join, map, qw/STRING/, reverse, sort, unpack
96
97 Functions for real %HASHes:
98      delete, each, exists, keys, values
99
100 Input and output functions:
101      binmode, close, closedir, dbmclose, dbmopen, die, eof,
102      fileno, flock, format, getc, print, printf, read, readdir,
103      readline, rewinddir, seek, seekdir, select, syscall,
104      sysread, sysseek, syswrite, tell, telldir, truncate, warn,
105      write
106
107 Functions for fixed length data or records:
108      pack, read, syscall, sysread, sysseek, syswrite, unpack,
109      vec
110
111 Functions for filehandles, files, or directories:
112      -X, chdir, chmod, chown, chroot, fcntl, glob, ioctl, link,
113      lstat, mkdir, open, opendir, readlink, rename, rmdir,
114      stat, symlink, umask, unlink, utime
115
116 Keywords related to control flow of your perl program:
117      caller, continue, die, do, dump, eval, exit, goto, last,
118      next, prototype, redo, return, sub, wantarray
119
120 Keywords altering or affecting scoping of identifiers:
121      caller, import, local, my, our, package, use
122
123 Miscellaneous functions:
124      defined, dump, eval, formline, local, my, our, prototype,
125      reset, scalar, undef, wantarray
126
127 Functions for processes and process groups:
128      alarm, exec, fork, getpgrp, getppid, getpriority, kill,
129      pipe, qx/STRING/, setpgrp, setpriority, sleep, system,
130      times, wait, waitpid
131
132 Keywords related to perl modules:
133      do, import, no, package, require, use
134
135 Keywords related to classes and object-orientedness:
136      bless, dbmclose, dbmopen, package, ref, tie, untie, use
137
138 Low-level socket functions:
139      accept, bind, connect, getpeername, getsockname,
140      getsockopt, listen, recv, send, setsockopt, shutdown,
141      socket, socketpair
142
143 System V interprocess communication functions:
144      msgctl, msgget, msgrcv, msgsnd, semctl, semget, semop,
145      shmctl, shmget, shmread, shmwrite
146
147 Fetching user and group info:
148      endgrent, endhostent, endnetent, endpwent, getgrent,
149      getgrgid, getgrnam, getlogin, getpwent, getpwnam,
150      getpwuid, setgrent, setpwent
151
152 Fetching network info:
153      endprotoent, endservent, gethostbyaddr, gethostbyname,
154      gethostent, getnetbyaddr, getnetbyname, getnetent,
155      getprotobyname, getprotobynumber, getprotoent,
156      getservbyname, getservbyport, getservent, sethostent,
157      setnetent, setprotoent, setservent
158
159 Time-related functions:
160      gmtime, localtime, time, times