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