1#!./perl -w 2 3use strict; 4use Test::More; 5use Config; 6 7plan(skip_all => "POSIX is unavailable") 8 unless $Config{extensions} =~ /\bPOSIX\b/; 9 10require POSIX; 11 12foreach ([atexit => 'C-specific: use END {} instead'], 13 [atof => 'C-specific, stopped'], 14 [atoi => 'C-specific, stopped'], 15 [atol => 'C-specific, stopped'], 16 [bsearch => 'not supplied'], 17 [calloc => 'C-specific, stopped'], 18 [clearerr => \'IO::Handle::clearerr'], 19 [div => 'C-specific: use /, % and int instead'], 20 [execl => 'C-specific, stopped'], 21 [execle => 'C-specific, stopped'], 22 [execlp => 'C-specific, stopped'], 23 [execv => 'C-specific, stopped'], 24 [execve => 'C-specific, stopped'], 25 [execvp => 'C-specific, stopped'], 26 [fclose => \'IO::Handle::close'], 27 [fdopen => \'IO::Handle::new_from_fd'], 28 [feof => \'IO::Handle::eof'], 29 [ferror => \'IO::Handle::error'], 30 [fflush => \'IO::Handle::flush'], 31 [fgetc => \'IO::Handle::getc'], 32 [fgetpos => \'IO::Seekable::getpos'], 33 [fgets => \'IO::Handle::gets'], 34 [fileno => \'IO::Handle::fileno'], 35 [fopen => \'IO::File::open'], 36 [fprintf => 'C-specific: use printf instead'], 37 [fputc => 'C-specific: use print instead'], 38 [fputs => 'C-specific: use print instead'], 39 [fread => 'C-specific: use read instead'], 40 [free => 'C-specific, stopped'], 41 [freopen => 'C-specific: use open instead'], 42 [fscanf => 'C-specific: use <> and regular expressions instead'], 43 [fseek => \'IO::Seekable::seek'], 44 [fsetpos => \'IO::Seekable::setpos'], 45 [fsync => \'IO::Handle::sync'], 46 [ftell => \'IO::Seekable::tell'], 47 [fwrite => 'C-specific: use print instead'], 48 [labs => 'C-specific: use abs instead'], 49 [ldiv => 'C-specific: use /, % and int instead'], 50 [longjmp => 'C-specific: use die instead'], 51 [malloc => 'C-specific, stopped'], 52 [memchr => 'C-specific: use index() instead'], 53 [memcmp => 'C-specific: use eq instead'], 54 [memcpy => 'C-specific: use = instead'], 55 [memmove => 'C-specific: use = instead'], 56 [memset => 'C-specific: use x instead'], 57 [offsetof => 'C-specific, stopped'], 58 [putc => 'C-specific: use print instead'], 59 [putchar => 'C-specific: use print instead'], 60 [puts => 'C-specific: use print instead'], 61 [qsort => 'C-specific: use sort instead'], 62 [rand => 'non-portable, use Perl\'s rand instead'], 63 [realloc => 'C-specific, stopped'], 64 [scanf => 'C-specific: use <> and regular expressions instead'], 65 [setbuf => \'IO::Handle::setbuf'], 66 [setjmp => 'C-specific: use eval {} instead'], 67 [setvbuf => \'IO::Handle::setvbuf'], 68 [siglongjmp => 'C-specific: use die instead'], 69 [sigsetjmp => 'C-specific: use eval {} instead'], 70 [srand => 'not supplied; refer to Perl\'s srand documentation'], 71 [sscanf => 'C-specific: use regular expressions instead'], 72 [strcat => 'C-specific: use .= instead'], 73 [strchr => 'C-specific: use index() instead'], 74 [strcmp => 'C-specific: use eq instead'], 75 [strcpy => 'C-specific: use = instead'], 76 [strcspn => 'C-specific: use regular expressions instead'], 77 [strlen => 'C-specific: use length instead'], 78 [strncat => 'C-specific: use .= instead'], 79 [strncmp => 'C-specific: use eq instead'], 80 [strncpy => 'C-specific: use = instead'], 81 [strpbrk => 'C-specific, stopped'], 82 [strrchr => 'C-specific: use rindex() instead'], 83 [strspn => 'C-specific, stopped'], 84 [strtok => 'C-specific, stopped'], 85 [tmpfile => \'IO::File::new_tmpfile'], 86 [tmpnam => \'use File::Temp'], 87 [ungetc => \'IO::Handle::ungetc'], 88 [vfprintf => 'C-specific, stopped'], 89 [vprintf => 'C-specific, stopped'], 90 [vsprintf => 'C-specific, stopped'], 91 [L_tmpnam => 'C-specific, stopped'], 92 ) { 93 my ($func, $action) = @$_; 94 my $expect = ref $action 95 ? qr/Unimplemented: POSIX::$func\(\): .*$$action(?:\(\))? instead at \(eval/ 96 : qr/Unimplemented: POSIX::$func\(\): \Q$action\E at \(eval/; 97 is(eval "POSIX::$func(); 1", undef, "POSIX::$func fails as expected"); 98 like($@, $expect, "POSIX::$func gives expected error message"); 99} 100 101done_testing(); 102