Fix [perl #66970] Incorrect coderef in MODIFY_CODE_ATTRIBUTES
[p5sagit/p5-mst-13.2.git] / ext / Win32 / t / GetCurrentThreadId.t
1 use strict;
2 use Config qw(%Config);
3 use Test;
4 use Win32;
5
6 my $fork_emulation = $Config{ccflags} =~ /PERL_IMPLICIT_SYS/;
7
8 my $tests = $fork_emulation ? 4 : 2;
9 plan tests => $tests;
10
11 my $pid = $$+0; # make sure we don't copy any magic to $pid
12
13 if ($^O eq "cygwin") {
14     skip(!defined &Cygwin::pid_to_winpid,
15          Cygwin::pid_to_winpid($pid),
16          Win32::GetCurrentProcessId());
17 }
18 else {
19     ok($pid, Win32::GetCurrentProcessId());
20 }
21
22 if ($fork_emulation) {
23     # This test relies on the implementation detail that the fork() emulation
24     # uses the negative value of the thread id as a pseudo process id.
25     if (my $child = fork) {
26         waitpid($child, 0);
27         exit 0;
28     }
29     ok(-$$, Win32::GetCurrentThreadId());
30
31     # GetCurrentProcessId() should still return the real PID
32     ok($pid, Win32::GetCurrentProcessId());
33     ok($$ != Win32::GetCurrentProcessId());
34 }
35 else {
36     # here we just want to see something.
37     ok(Win32::GetCurrentThreadId() > 0);
38 }