xref: /openbsd/gnu/usr.bin/perl/os2/os2_base.t (revision 85009909)
1#!/usr/bin/perl -w
2BEGIN {
3    chdir 't' if -d 't';
4    @INC = '../lib';
5}
6
7use Test::More tests => 19;
8use strict;
9use Config;
10
11my $cwd = Cwd::sys_cwd();
12ok -d $cwd;
13
14my $lpb = Cwd::extLibpath;
15$lpb .= ';' unless $lpb and $lpb =~ /;$/;
16
17my $lpe = Cwd::extLibpath(1);
18$lpe .= ';' unless $lpe and $lpe =~ /;$/;
19
20ok Cwd::extLibpath_set("$lpb$cwd");
21
22$lpb = Cwd::extLibpath;
23$lpb =~ s#\\#/#g;
24(my $s_cwd = $cwd) =~ s#\\#/#g;
25
26like($lpb, qr/\Q$s_cwd/);
27
28ok Cwd::extLibpath_set("$lpe$cwd", 1);
29
30$lpe = Cwd::extLibpath(1);
31$lpe =~ s#\\#/#g;
32
33like($lpe, qr/\Q$s_cwd/);
34
35if (uc OS2::DLLname() eq uc $^X) {	# Static build
36  my ($short) = ($^X =~ m,.*[/\\]([^.]+),);
37  is(uc OS2::DLLname(1), uc $short);
38  is(uc OS2::DLLname, uc $^X );		# automatically
39  is(1,1);				# automatically...
40} else {
41  is(uc OS2::DLLname(1), uc $Config{dll_name});
42  like(OS2::DLLname, qr#\Q/$Config{dll_name}\E\.dll$#i );
43  (my $root_cwd = $s_cwd) =~ s,/t$,,;
44  like(OS2::DLLname, qr#^\Q$root_cwd\E(/t)?\Q/$Config{dll_name}\E\.dll#i );
45}
46is(OS2::DLLname, OS2::DLLname(2));
47like(OS2::DLLname(0), qr#^(\d+)$# );
48
49
50is(OS2::DLLname($_), OS2::DLLname($_, \&Cwd::extLibpath) ) for 0..2;
51ok(not defined eval { OS2::DLLname $_, \&Cwd::cwd; 1 } ) for 0..2;
52ok(not defined eval { OS2::DLLname $_, \&xxx; 1 } ) for 0..2;
53