This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add z/OS locale categories
[perl5.git] / ext / POSIX / t / export.t
CommitLineData
57159ffe
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;
11POSIX->import();
12
13# @POSIX::EXPORT and @POSIX::EXPORT_OK are generated. The intent of this test is
14# to catch *unintended* changes to them introduced by bugs in refactoring.
15
86c35584
AP
16# N.B. the data must be sorted at runtime even though it appears sorted here
17# because it is given in ASCII order and we might be on a non-ASCII platform
57159ffe 18my %expect = (
7658eeca
AP
19 EXPORT => [sort
20 # this stuff was in 5.20.2
21 qw(
22 %SIGRT ARG_MAX B0 B110 B1200 B134 B150 B1800 B19200 B200
23 B2400 B300 B38400 B4800 B50 B600 B75 B9600 BRKINT BUFSIZ
24 CHAR_BIT CHAR_MAX CHAR_MIN CHILD_MAX CLK_TCK CLOCAL
25 CLOCKS_PER_SEC CREAD CS5 CS6 CS7 CS8 CSIZE CSTOPB DBL_DIG
26 DBL_EPSILON DBL_MANT_DIG DBL_MAX DBL_MAX_10_EXP DBL_MAX_EXP
27 DBL_MIN DBL_MIN_10_EXP DBL_MIN_EXP E2BIG EACCES EADDRINUSE
28 EADDRNOTAVAIL EAFNOSUPPORT EAGAIN EALREADY EBADF EBADMSG EBUSY
29 ECANCELED ECHILD ECHO ECHOE ECHOK ECHONL ECONNABORTED
30 ECONNREFUSED ECONNRESET EDEADLK EDESTADDRREQ EDOM EDQUOT
31 EEXIST EFAULT EFBIG EHOSTDOWN EHOSTUNREACH EIDRM EILSEQ
32 EINPROGRESS EINTR EINVAL EIO EISCONN EISDIR ELOOP EMFILE
33 EMLINK EMSGSIZE ENAMETOOLONG ENETDOWN ENETRESET ENETUNREACH
34 ENFILE ENOBUFS ENODATA ENODEV ENOENT ENOEXEC ENOLCK ENOLINK
35 ENOMEM ENOMSG ENOPROTOOPT ENOSPC ENOSR ENOSTR ENOSYS ENOTBLK
36 ENOTCONN ENOTDIR ENOTEMPTY ENOTRECOVERABLE ENOTSOCK ENOTSUP
37 ENOTTY ENXIO EOF EOPNOTSUPP EOTHER EOVERFLOW EOWNERDEAD EPERM
38 EPFNOSUPPORT EPIPE EPROCLIM EPROTO EPROTONOSUPPORT EPROTOTYPE
39 ERANGE EREMOTE ERESTART EROFS ESHUTDOWN ESOCKTNOSUPPORT ESPIPE
40 ESRCH ESTALE ETIME ETIMEDOUT ETOOMANYREFS ETXTBSY EUSERS
41 EWOULDBLOCK EXDEV
42 EXIT_FAILURE EXIT_SUCCESS FD_CLOEXEC FILENAME_MAX
43 FLT_DIG FLT_EPSILON FLT_MANT_DIG FLT_MAX FLT_MAX_10_EXP
44 FLT_MAX_EXP FLT_MIN FLT_MIN_10_EXP FLT_MIN_EXP FLT_RADIX
45 FLT_ROUNDS F_DUPFD F_GETFD F_GETFL F_GETLK F_OK F_RDLCK
46 F_SETFD F_SETFL F_SETLK F_SETLKW F_UNLCK F_WRLCK HUGE_VAL
47 HUPCL ICANON ICRNL IEXTEN IGNBRK IGNCR IGNPAR INLCR INPCK
9821811f
KW
48 INT_MAX INT_MIN ISIG ISTRIP IXOFF IXON
49 LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION
50 LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NUMERIC LC_PAPER
36dbc955 51 LC_TELEPHONE LC_TIME LC_SYNTAX LC_TOD LDBL_DIG
7658eeca
AP
52 LDBL_EPSILON LDBL_MANT_DIG LDBL_MAX LDBL_MAX_10_EXP
53 LDBL_MAX_EXP LDBL_MIN LDBL_MIN_10_EXP LDBL_MIN_EXP LINK_MAX
1cb852db 54 LONG_MAX LONG_MIN L_ctermid L_cuserid MAX_CANON
7658eeca
AP
55 MAX_INPUT MB_CUR_MAX MB_LEN_MAX NAME_MAX NCCS NDEBUG
56 NGROUPS_MAX NOFLSH NULL OPEN_MAX OPOST O_ACCMODE O_APPEND
57 O_CREAT O_EXCL O_NOCTTY O_NONBLOCK O_RDONLY O_RDWR O_TRUNC
58 O_WRONLY PARENB PARMRK PARODD PATH_MAX PIPE_BUF RAND_MAX R_OK
59 SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK SA_RESETHAND
60 SA_RESTART SA_SIGINFO SCHAR_MAX SCHAR_MIN SEEK_CUR SEEK_END
61 SEEK_SET SHRT_MAX SHRT_MIN SIGABRT SIGALRM SIGBUS SIGCHLD
62 SIGCONT SIGFPE SIGHUP SIGILL SIGINT SIGKILL SIGPIPE SIGPOLL
63 SIGPROF SIGQUIT SIGRTMAX SIGRTMIN SIGSEGV SIGSTOP SIGSYS
64 SIGTERM SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGURG SIGUSR1
65 SIGUSR2 SIGVTALRM SIGXCPU SIGXFSZ SIG_BLOCK SIG_DFL SIG_ERR
66 SIG_IGN SIG_SETMASK SIG_UNBLOCK SSIZE_MAX STDERR_FILENO
67 STDIN_FILENO STDOUT_FILENO STREAM_MAX S_IRGRP S_IROTH S_IRUSR
68 S_IRWXG S_IRWXO S_IRWXU S_ISBLK S_ISCHR S_ISDIR S_ISFIFO
69 S_ISGID S_ISREG S_ISUID S_IWGRP S_IWOTH S_IWUSR S_IXGRP
70 S_IXOTH S_IXUSR TCIFLUSH TCIOFF TCIOFLUSH TCION TCOFLUSH
71 TCOOFF TCOON TCSADRAIN TCSAFLUSH TCSANOW TMP_MAX TOSTOP
72 TZNAME_MAX UCHAR_MAX UINT_MAX ULONG_MAX USHRT_MAX VEOF VEOL
73 VERASE VINTR VKILL VMIN VQUIT VSTART VSTOP VSUSP VTIME
74 WEXITSTATUS WIFEXITED WIFSIGNALED WIFSTOPPED WNOHANG WSTOPSIG
75 WTERMSIG WUNTRACED W_OK X_OK _PC_CHOWN_RESTRICTED
76 _PC_LINK_MAX _PC_MAX_CANON _PC_MAX_INPUT _PC_NAME_MAX
77 _PC_NO_TRUNC _PC_PATH_MAX _PC_PIPE_BUF _PC_VDISABLE
78 _POSIX_ARG_MAX _POSIX_CHILD_MAX _POSIX_CHOWN_RESTRICTED
79 _POSIX_JOB_CONTROL _POSIX_LINK_MAX _POSIX_MAX_CANON
80 _POSIX_MAX_INPUT _POSIX_NAME_MAX _POSIX_NGROUPS_MAX
81 _POSIX_NO_TRUNC _POSIX_OPEN_MAX _POSIX_PATH_MAX
82 _POSIX_PIPE_BUF _POSIX_SAVED_IDS _POSIX_SSIZE_MAX
83 _POSIX_STREAM_MAX _POSIX_TZNAME_MAX _POSIX_VDISABLE
84 _POSIX_VERSION _SC_ARG_MAX _SC_CHILD_MAX _SC_CLK_TCK
85 _SC_JOB_CONTROL _SC_NGROUPS_MAX _SC_OPEN_MAX _SC_PAGESIZE
86 _SC_SAVED_IDS _SC_STREAM_MAX _SC_TZNAME_MAX _SC_VERSION _exit
87 abort access acos asctime asin assert atan atexit atof atoi
88 atol bsearch calloc ceil cfgetispeed cfgetospeed cfsetispeed
89 cfsetospeed clearerr clock cosh creat ctermid ctime cuserid
90 difftime div dup dup2 errno execl execle execlp execv execve
91 execvp fabs fclose fdopen feof ferror fflush fgetc fgetpos
92 fgets floor fmod fopen fpathconf fprintf fputc fputs fread
93 free freopen frexp fscanf fseek fsetpos fstat fsync ftell
94 fwrite getchar getcwd getegid getenv geteuid getgid getgroups
a65dc09f 95 getpid gets getuid isatty labs
7658eeca
AP
96 ldexp ldiv localeconv log10 longjmp lseek malloc mblen
97 mbstowcs mbtowc memchr memcmp memcpy memmove memset mkfifo
98 mktime modf offsetof pathconf pause perror pow putc putchar
99 puts qsort raise realloc remove rewind scanf setbuf setgid
100 setjmp setlocale setpgid setsid setuid setvbuf sigaction
101 siglongjmp signal sigpending sigprocmask sigsetjmp sigsuspend
102 sinh sscanf stderr stdin stdout strcat strchr strcmp strcoll
103 strcpy strcspn strerror strftime strlen strncat strncmp
104 strncpy strpbrk strrchr strspn strstr strtod strtok strtol
105 strtoul strxfrm sysconf tan tanh tcdrain tcflow tcflush
106 tcgetattr tcgetpgrp tcsendbreak tcsetattr tcsetpgrp tmpfile
a65dc09f 107 tmpnam ttyname tzname tzset uname ungetc
7658eeca
AP
108 vfprintf vprintf vsprintf wcstombs wctomb
109 ),
110 # this stuff was added in 5.21
111 qw(
112 FP_ILOGB0 FP_ILOGBNAN FP_INFINITE FP_NAN FP_NORMAL FP_SUBNORMAL FP_ZERO
113 M_1_PI M_2_PI M_2_SQRTPI M_E M_LN10 M_LN2 M_LOG10E M_LOG2E M_PI
114 M_PI_2 M_PI_4 M_SQRT1_2 M_SQRT2 INFINITY NAN
115 ),
a28fff51
SH
116 # this stuff was added for Windows in 5.23
117 ($^O eq 'MSWin32' ? qw(
118 WSAEINTR WSAEBADF WSAEACCES WSAEFAULT WSAEINVAL WSAEMFILE WSAEWOULDBLOCK
119 WSAEINPROGRESS WSAEALREADY WSAENOTSOCK WSAEDESTADDRREQ WSAEMSGSIZE
120 WSAEPROTOTYPE WSAENOPROTOOPT WSAEPROTONOSUPPORT WSAESOCKTNOSUPPORT
121 WSAEOPNOTSUPP WSAEPFNOSUPPORT WSAEAFNOSUPPORT WSAEADDRINUSE
122 WSAEADDRNOTAVAIL WSAENETDOWN WSAENETUNREACH WSAENETRESET WSAECONNABORTED
123 WSAECONNRESET WSAENOBUFS WSAEISCONN WSAENOTCONN WSAESHUTDOWN
124 WSAETOOMANYREFS WSAETIMEDOUT WSAECONNREFUSED WSAELOOP WSAENAMETOOLONG
125 WSAEHOSTDOWN WSAEHOSTUNREACH WSAENOTEMPTY WSAEPROCLIM WSAEUSERS
126 WSAEDQUOT WSAESTALE WSAEREMOTE WSAEDISCON WSAENOMORE WSAECANCELLED
127 WSAEINVALIDPROCTABLE WSAEINVALIDPROVIDER WSAEPROVIDERFAILEDINIT
128 WSAEREFUSED
129 ) : ()),
7658eeca
AP
130 # adding new functions to EXPORT is a BACKWARD COMPATIBILITY BREAKING CHANGE
131 # it is OK to add new constants, but new functions may only go in EXPORT_OK
132 ],
133 EXPORT_OK => [sort
b40d1aa2
AC
134 # this stuff was added in 5.9, but not exported until 5.25
135 qw(
136 MSG_CTRUNC MSG_DONTROUTE MSG_EOR MSG_OOB MSG_PEEK
137 MSG_TRUNC MSG_WAITALL
138 ),
9a0b3f36
AC
139 # this stuff was added in 5.11, but not exported until 5.25
140 qw(
141 EAI_AGAIN EAI_BADFLAGS EAI_FAIL EAI_FAMILY EAI_MEMORY
142 EAI_NONAME EAI_OVERFLOW EAI_SERVICE EAI_SOCKTYPE EAI_SYSTEM
143 ),
7658eeca
AP
144 # this stuff was in 5.20.2
145 qw(
146 abs alarm atan2 chdir chmod chown close closedir cos exit
147 exp fcntl fileno fork getc getgrgid getgrnam getlogin
148 getpgrp getppid getpwnam getpwuid gmtime kill lchown link
149 localtime log mkdir nice open opendir pipe printf rand
150 read readdir rename rewinddir rmdir sin sleep sprintf sqrt
151 srand stat system time times umask unlink utime wait
1cb852db 152 waitpid write L_tmpnam
7658eeca
AP
153 ),
154 # this stuff was added in 5.21
decf70bc
AC
155 # (though an oversight meant that lround wasn't listed here
156 # initially; it was added to @EXPORT_OK in 5.23, and to the
157 # :math_h_c99 tag in 5.25)
7658eeca
AP
158 qw(
159 FE_DOWNWARD FE_TONEAREST FE_TOWARDZERO FE_UPWARD
160 fegetround fesetround
161 Inf NaN
162 acosh asinh atanh cbrt copysign erf erfc exp2 expm1 fdim
163 fma fmax fmin fpclassify hypot ilogb isfinite isgreater
164 isgreaterequal isinf isless islessequal islessgreater isnan
decf70bc 165 isnormal isunordered j0 j1 jn lgamma log1p log2 logb lrint lround nan
7658eeca
AP
166 nearbyint nextafter nexttoward remainder remquo rint round scalbn
167 signbit tgamma trunc y0 y1 yn strtold
168 ),
07bb61ac
JH
169 # this stuff was added in 5.23
170 qw(
171 getpayload issignaling setpayload setpayloadsig
34e79b75
DIM
172 ILL_ILLOPC ILL_ILLOPN ILL_ILLADR ILL_ILLTRP ILL_PRVOPC ILL_PRVREG
173 ILL_COPROC ILL_BADSTK
174 FPE_INTDIV FPE_INTOVF FPE_FLTDIV FPE_FLTOVF FPE_FLTUND
175 FPE_FLTRES FPE_FLTINV FPE_FLTSUB
176 SEGV_MAPERR SEGV_ACCERR
177 BUS_ADRALN BUS_ADRERR BUS_OBJERR
178 TRAP_BRKPT TRAP_TRACE
179 CLD_EXITED CLD_KILLED CLD_DUMPED CLD_TRAPPED CLD_STOPPED CLD_CONTINUED
180 POLL_IN POLL_OUT POLL_MSG POLL_ERR POLL_PRI POLL_HUP
181 SI_USER SI_QUEUE SI_TIMER SI_ASYNCIO SI_MESGQ
07bb61ac 182 ),
4fd667a8
TC
183 # added in 5.27
184 qw(
185 PRIO_PROCESS PRIO_PGRP PRIO_USER
186 ),
7658eeca 187 ],
86c35584 188);
57159ffe 189
a26223c9 190plan (tests => 2 * keys(%expect) + keys(%POSIX::));
57159ffe
NC
191
192while (my ($var, $expect) = each %expect) {
193 my $have = *{$POSIX::{$var}}{ARRAY};
194 cmp_ok(@$have, '==', @$expect,
195 "Correct number of entries for \@POSIX::$var");
86c35584 196 is_deeply([sort @$have], $expect, "Correct entries for \@POSIX::$var");
57159ffe 197}
a26223c9
AC
198
199my %no_export_needed = map +($_ => 1),
200 qw(AUTOLOAD bootstrap constant croak import load_imports
201 unimplemented_message usage);
202
203my %exported = map +($_ => 1),
204 (@POSIX::EXPORT, @POSIX::EXPORT_OK, map @$_, values %POSIX::EXPORT_TAGS);
205
206for my $name (sort keys %POSIX::) {
207 my $code = do { no strict 'refs'; \&{"POSIX::$name"} };
208 if (!defined &$code) {
209 pass("$name need not be exported as it does not name a subroutine");
210 }
211 elsif ($no_export_needed{$name}) {
212 pass("$name need not be exported as it is part of the internals");
213 }
214 else {
215 ok($exported{$name}, "subroutine POSIX::$name is exported somehow");
216 }
217}