~ubuntu-branches/ubuntu/oneiric/swig1.3/oneiric

« back to all changes in this revision

Viewing changes to Examples/test-suite/perl5/reference_global_vars_runme.pl

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2008-11-10 16:29:56 UTC
  • mfrom: (1.2.8 upstream) (2.1.3 lenny)
  • Revision ID: james.westby@ubuntu.com-20081110162956-xue6itkuqhbza87s
Tags: 1.3.36-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Drop pike and libchicken-dev from the build-depends 
    (both are universe)
  - Use python2.5 instead of python2.4.
  - use php5
  - Clean Runtime/ as well.
  - debian/Rules (clean): Remove Lib/ocaml/swigp4.ml.
  - drop "--without-mzscheme", we don't have it in our build-depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
use strict;
 
3
use warnings;
 
4
use Test::More tests => 19;
 
5
BEGIN { use_ok('reference_global_vars') }
 
6
require_ok('reference_global_vars');
 
7
 
 
8
# adapted from ../python/reference_global_vars_runme.py
 
9
 
 
10
my $cvar;
 
11
{
 
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};
 
17
}
 
18
 
 
19
is(getconstTC()->{num}, 33);
 
20
 
 
21
# primitive reference variables
 
22
$cvar->{var_bool} = createref_bool(0);
 
23
is(value_bool($cvar->{var_bool}), '');
 
24
 
 
25
$cvar->{var_bool} = createref_bool(1);
 
26
is(value_bool($cvar->{var_bool}), 1);
 
27
 
 
28
$cvar->{var_char} = createref_char('w');
 
29
is(value_char($cvar->{var_char}), 'w');
 
30
 
 
31
$cvar->{var_unsigned_char} = createref_unsigned_char(10);
 
32
is(value_unsigned_char($cvar->{var_unsigned_char}), 10);
 
33
 
 
34
$cvar->{var_signed_char} = createref_signed_char(10);
 
35
is(value_signed_char($cvar->{var_signed_char}), 10);
 
36
 
 
37
$cvar->{var_short} = createref_short(10);
 
38
is(value_short($cvar->{var_short}), 10);
 
39
 
 
40
$cvar->{var_unsigned_short} = createref_unsigned_short(10);
 
41
is(value_unsigned_short($cvar->{var_unsigned_short}), 10);
 
42
 
 
43
$cvar->{var_int} = createref_int(10);
 
44
is(value_int($cvar->{var_int}), 10);
 
45
 
 
46
$cvar->{var_unsigned_int} = createref_unsigned_int(10);
 
47
is(value_unsigned_int($cvar->{var_unsigned_int}), 10);
 
48
 
 
49
$cvar->{var_long} = createref_long(10);
 
50
is(value_long($cvar->{var_long}), 10);
 
51
 
 
52
$cvar->{var_unsigned_long} = createref_unsigned_long(10);
 
53
is(value_unsigned_long($cvar->{var_unsigned_long}), 10);
 
54
 
 
55
SKIP: {
 
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);
 
62
}
 
63
 
 
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);
 
68
 
 
69
$cvar->{var_float} = createref_float(10.5);
 
70
is(value_float($cvar->{var_float}), 10.5);
 
71
 
 
72
$cvar->{var_double} = createref_double(10.5);
 
73
is(value_double($cvar->{var_double}), 10.5);
 
74
 
 
75
# class reference variable
 
76
$cvar->{var_TestClass} = createref_TestClass(
 
77
        TestClass->new(20)
 
78
);
 
79
is(value_TestClass($cvar->{var_TestClass})->{num}, 20);
 
80