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 38is_deeply( \@Type_Order, \@categories, 39 '@Type_Order' ); 40 41my @cat_keys = grep exists $Type_Description{ $_ } => @Type_Order; 42 43is_deeply( \@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, method, next, redo, return, sub, wantarray 119 120Keywords related to scoping: 121 caller, class, field, import, local, my, our, package, 122 state, use 123 124Miscellaneous functions: 125 defined, formline, lock, prototype, reset, scalar, undef 126 127Functions for processes and process groups: 128 alarm, exec, fork, getpgrp, getppid, getpriority, kill, 129 pipe, qx/STRING/, readpipe, setpgrp, setpriority, sleep, 130 system, times, wait, waitpid 131 132Keywords related to Perl modules: 133 do, import, no, package, require, use 134 135Keywords related to classes and object-orientation: 136 __CLASS__, bless, class, dbmclose, dbmopen, field, method, 137 package, ref, tie, tied, untie, use 138 139Low-level socket functions: 140 accept, bind, connect, getpeername, getsockname, 141 getsockopt, listen, recv, send, setsockopt, shutdown, 142 socket, socketpair 143 144System V interprocess communication functions: 145 msgctl, msgget, msgrcv, msgsnd, semctl, semget, semop, 146 shmctl, shmget, shmread, shmwrite 147 148Fetching user and group info: 149 endgrent, endhostent, endnetent, endpwent, getgrent, 150 getgrgid, getgrnam, getlogin, getpwent, getpwnam, 151 getpwuid, setgrent, setpwent 152 153Fetching network info: 154 endprotoent, endservent, gethostbyaddr, gethostbyname, 155 gethostent, getnetbyaddr, getnetbyname, getnetent, 156 getprotobyname, getprotobynumber, getprotoent, 157 getservbyname, getservbyport, getservent, sethostent, 158 setnetent, setprotoent, setservent 159 160Time-related functions: 161 gmtime, localtime, time, times 162