PageRenderTime 24ms CodeModel.GetById 1ms app.highlight 19ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/perl5/li_reference_runme.pl

#
Perl | 36 lines | 35 code | 1 blank | 0 comment | 0 complexity | 35413d5cf8da94989d8e537cc0453ce1 MD5 | raw file
 1use strict;
 2use warnings;
 3use Test::More tests => 68;
 4BEGIN { use_ok('li_reference') }
 5require_ok('li_reference');
 6
 7sub chk { my($type, $call, $v1, $v2) = @_;
 8    $li_reference::FrVal = $v1;
 9    my $v = $v2;
10    eval { $call->(\$v) };
11    is($@, '', "$type check");
12    is($li_reference::ToVal, $v2, "$type out");
13    is($v, $v1, "$type in");
14}
15chk("double*", \&li_reference::PDouble, 12.2, 18.6);
16chk("double&", \&li_reference::RDouble, 32.5, 64.8);
17chk("float*",  \&li_reference::PFloat,  64.5, 96.0);
18chk("float&",  \&li_reference::RFloat,  98.5, 6.25);
19chk("int*",    \&li_reference::PInt,    1887, 3356);
20chk("int&",    \&li_reference::RInt,    2622, 9867);
21chk("short*",  \&li_reference::PShort,  4752, 3254);
22chk("short&",  \&li_reference::RShort,  1898, 5757);
23chk("long*",   \&li_reference::PLong,   6687, 7132);
24chk("long&",   \&li_reference::RLong,   8346, 4398);
25chk("uint*",   \&li_reference::PUInt,   6853, 5529);
26chk("uint&",   \&li_reference::RUInt,   5483, 7135);
27chk("ushort*", \&li_reference::PUShort, 9960, 9930);
28chk("ushort&", \&li_reference::RUShort, 1193, 4178);
29chk("ulong*",  \&li_reference::PULong,  7960, 4788);
30chk("ulong&",  \&li_reference::RULong,  8829, 1603);
31chk("uchar*",  \&li_reference::PUChar,  110,  239);
32chk("uchar&",  \&li_reference::RUChar,  15,   97);
33chk("char*",   \&li_reference::PChar,   -7,   118);
34chk("char&",   \&li_reference::RChar,   -3,  -107);
35chk("bool*",   \&li_reference::PBool,   0,    1);
36chk("bool&",   \&li_reference::RBool,   1,    0);