xref: /openbsd-src/gnu/usr.bin/perl/dist/ExtUtils-ParseXS/t/511-t-whitespace.t (revision 898184e3e61f9129feb5978fad5a8c6865f00b92)
1*898184e3Ssthen#!/usr/bin/perl
2*898184e3Ssthenuse strict;
3*898184e3Ssthenuse warnings;
4*898184e3Ssthen
5*898184e3Ssthenuse Test::More tests => 2;
6*898184e3Ssthenuse ExtUtils::Typemaps;
7*898184e3Ssthen
8*898184e3SsthenSCOPE: {
9*898184e3Ssthen  my $map = ExtUtils::Typemaps->new();
10*898184e3Ssthen  $map->add_typemap(ctype => 'unsigned int', xstype => 'T_UV');
11*898184e3Ssthen  $map->add_inputmap(xstype => 'T_UV', code => '  $var = ($type)SvUV($arg);');
12*898184e3Ssthen  is($map->as_string(), <<'HERE', "Simple typemap (with input and code including leading whitespace) matches expectations");
13*898184e3SsthenTYPEMAP
14*898184e3Ssthenunsigned int	T_UV
15*898184e3Ssthen
16*898184e3SsthenINPUT
17*898184e3SsthenT_UV
18*898184e3Ssthen  $var = ($type)SvUV($arg);
19*898184e3SsthenHERE
20*898184e3Ssthen}
21*898184e3Ssthen
22*898184e3Ssthen
23*898184e3SsthenSCOPE: {
24*898184e3Ssthen  my $map = ExtUtils::Typemaps->new();
25*898184e3Ssthen  $map->add_typemap(ctype => 'unsigned int', xstype => 'T_UV');
26*898184e3Ssthen  $map->add_inputmap(xstype => 'T_UV', code => "  \$var =\n(\$type)\n          SvUV(\$arg);");
27*898184e3Ssthen  is($map->as_string(), <<'HERE', "Simple typemap (with input and multi-line code) matches expectations");
28*898184e3SsthenTYPEMAP
29*898184e3Ssthenunsigned int	T_UV
30*898184e3Ssthen
31*898184e3SsthenINPUT
32*898184e3SsthenT_UV
33*898184e3Ssthen  $var =
34*898184e3Ssthen	($type)
35*898184e3Ssthen          SvUV($arg);
36*898184e3SsthenHERE
37*898184e3Ssthen}
38*898184e3Ssthen
39