This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Croak on unimplemented already at import time
[perl5.git] / ext / POSIX / t / unimplemented.t
CommitLineData
e61e2601
NC
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
96927498 12foreach ([atexit => 'C-specific: use END {} instead'],
3bc0fa49
NC
13 [atof => 'C-specific, stopped'],
14 [atoi => 'C-specific, stopped'],
15 [atol => 'C-specific, stopped'],
16 [bsearch => 'not supplied'],
17 [calloc => 'C-specific, stopped'],
e61e2601 18 [clearerr => \'IO::Handle::clearerr'],
96927498 19 [div => 'C-specific: use /, % and int instead'],
3bc0fa49
NC
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'],
e61e2601
NC
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'],
96927498
FC
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'],
3bc0fa49 40 [free => 'C-specific, stopped'],
96927498
FC
41 [freopen => 'C-specific: use open instead'],
42 [fscanf => 'C-specific: use <> and regular expressions instead'],
e61e2601
NC
43 [fseek => \'IO::Seekable::seek'],
44 [fsetpos => \'IO::Seekable::setpos'],
45 [fsync => \'IO::Handle::sync'],
46 [ftell => \'IO::Seekable::tell'],
96927498
FC
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'],
3bc0fa49 51 [malloc => 'C-specific, stopped'],
96927498
FC
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'],
3bc0fa49 57 [offsetof => 'C-specific, stopped'],
96927498
FC
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'],
3bc0fa49
NC
62 [rand => 'non-portable, use Perl\'s rand instead'],
63 [realloc => 'C-specific, stopped'],
96927498 64 [scanf => 'C-specific: use <> and regular expressions instead'],
e61e2601 65 [setbuf => \'IO::Handle::setbuf'],
96927498 66 [setjmp => 'C-specific: use eval {} instead'],
e61e2601 67 [setvbuf => \'IO::Handle::setvbuf'],
96927498
FC
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'],
3bc0fa49 81 [strpbrk => 'C-specific, stopped'],
96927498 82 [strrchr => 'C-specific: use rindex() instead'],
3bc0fa49
NC
83 [strspn => 'C-specific, stopped'],
84 [strtok => 'C-specific, stopped'],
e61e2601 85 [tmpfile => \'IO::File::new_tmpfile'],
19fc2965 86 [tmpnam => \'use File::Temp'],
e61e2601 87 [ungetc => \'IO::Handle::ungetc'],
3bc0fa49
NC
88 [vfprintf => 'C-specific, stopped'],
89 [vprintf => 'C-specific, stopped'],
90 [vsprintf => 'C-specific, stopped'],
e61e2601
NC
91 ) {
92 my ($func, $action) = @$_;
11e7c26f 93 my $expect = ref $action
19fc2965
JH
94 ? qr/Unimplemented: POSIX::$func\(\): .*$$action(?:\(\))? instead at \(eval/
95 : qr/Unimplemented: POSIX::$func\(\): \Q$action\E at \(eval/;
e61e2601
NC
96 is(eval "POSIX::$func(); 1", undef, "POSIX::$func fails as expected");
97 like($@, $expect, "POSIX::$func gives expected error message");
98}
99
100done_testing();