4
use Test::More tests => 19;
5
BEGIN { use_ok('reference_global_vars') }
6
require_ok('reference_global_vars');
8
# adapted from ../python/reference_global_vars_runme.py
12
# don't try this at home kids... sneaking an import of all symbols
13
# from reference_global_vars to main because my fingers are getting
14
# sore from qualifying all these names. ;)
15
my $cvar = *reference_global_vars::;
16
map { ${*::}{$_} = ${$cvar}{$_} } keys %{$cvar};
19
is(getconstTC()->{num}, 33);
21
# primitive reference variables
22
$cvar->{var_bool} = createref_bool(0);
23
is(value_bool($cvar->{var_bool}), '');
25
$cvar->{var_bool} = createref_bool(1);
26
is(value_bool($cvar->{var_bool}), 1);
28
$cvar->{var_char} = createref_char('w');
29
is(value_char($cvar->{var_char}), 'w');
31
$cvar->{var_unsigned_char} = createref_unsigned_char(10);
32
is(value_unsigned_char($cvar->{var_unsigned_char}), 10);
34
$cvar->{var_signed_char} = createref_signed_char(10);
35
is(value_signed_char($cvar->{var_signed_char}), 10);
37
$cvar->{var_short} = createref_short(10);
38
is(value_short($cvar->{var_short}), 10);
40
$cvar->{var_unsigned_short} = createref_unsigned_short(10);
41
is(value_unsigned_short($cvar->{var_unsigned_short}), 10);
43
$cvar->{var_int} = createref_int(10);
44
is(value_int($cvar->{var_int}), 10);
46
$cvar->{var_unsigned_int} = createref_unsigned_int(10);
47
is(value_unsigned_int($cvar->{var_unsigned_int}), 10);
49
$cvar->{var_long} = createref_long(10);
50
is(value_long($cvar->{var_long}), 10);
52
$cvar->{var_unsigned_long} = createref_unsigned_long(10);
53
is(value_unsigned_long($cvar->{var_unsigned_long}), 10);
56
my $a = "6FFFFFFFFFFFFFF8";
57
skip "64 bit int support", 1 unless eval { pack 'q', 1 };
58
# using hex() here instead of a literal because non 64bit Perls will
59
# be noisy about big constants.
60
$cvar->{var_long_long} = createref_long_long(hex $a);
61
is(value_long_long($cvar->{var_long_long}), hex $a);
64
#ull = abs(0xFFFFFFF2FFFFFFF0)
65
my $ull = 55834574864;
66
$cvar->{var_unsigned_long_long} = createref_unsigned_long_long($ull);
67
is(value_unsigned_long_long($cvar->{var_unsigned_long_long}), $ull);
69
$cvar->{var_float} = createref_float(10.5);
70
is(value_float($cvar->{var_float}), 10.5);
72
$cvar->{var_double} = createref_double(10.5);
73
is(value_double($cvar->{var_double}), 10.5);
75
# class reference variable
76
$cvar->{var_TestClass} = createref_TestClass(
79
is(value_TestClass($cvar->{var_TestClass})->{num}, 20);