xref: /openbsd-src/gnu/usr.bin/perl/dist/threads/t/version.t (revision f2a19305cfc49ea4d1a5feb55cd6c283c6f1e031)
1*f2a19305Safresh1use strict;
2*f2a19305Safresh1use warnings;
3*f2a19305Safresh1use Test::More;
4*f2a19305Safresh1
5*f2a19305Safresh1BEGIN {
6*f2a19305Safresh1    use Config;
7*f2a19305Safresh1    if (! $Config{'useithreads'}) {
8*f2a19305Safresh1        print("1..0 # SKIP Perl not compiled with 'useithreads'\n");
9*f2a19305Safresh1        exit(0);
10*f2a19305Safresh1    }
11*f2a19305Safresh1}
12*f2a19305Safresh1
13*f2a19305Safresh1use threads;
14*f2a19305Safresh1
15*f2a19305Safresh1# test that the version documented in threads.pm pod matches
16*f2a19305Safresh1# that of the code.
17*f2a19305Safresh1
18*f2a19305Safresh1open my $fh, "<", $INC{"threads.pm"}
19*f2a19305Safresh1    or die qq(Failed to open '$INC{"threads.pm"}': $!);
20*f2a19305Safresh1my $file= do { local $/; <$fh> };
21*f2a19305Safresh1close $fh;
22*f2a19305Safresh1my $pod_version = 0;
23*f2a19305Safresh1if ($file=~/This document describes threads version (\d.\d+)/) {
24*f2a19305Safresh1    $pod_version = $1;
25*f2a19305Safresh1}
26*f2a19305Safresh1is($pod_version, $threads::VERSION,
27*f2a19305Safresh1   "Check that pod and \$threads::VERSION match");
28*f2a19305Safresh1done_testing();
29*f2a19305Safresh1
30*f2a19305Safresh1
31*f2a19305Safresh1
32