~ubuntu-branches/ubuntu/quantal/libglib-perl/quantal

« back to all changes in this revision

Viewing changes to t/tied_set_property.t

  • Committer: Package Import Robot
  • Author(s): Alessandro Ghedini
  • Date: 2011-10-14 13:25:08 UTC
  • mfrom: (9.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20111014132508-vfobq25fm504fvhb
Tags: 2:1.240-1
* New upstream release
* Refresh and update patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
package main;
 
4
use strict;
 
5
use warnings;
 
6
use Test::More tests => 1;
 
7
 
 
8
#------------------------------------------------------------------------------
 
9
 
 
10
package MaiTai;
 
11
use strict;
 
12
use warnings;
 
13
 
 
14
sub TIESCALAR {
 
15
  my ($class) = @_;
 
16
  return bless {}, $class;
 
17
}
 
18
 
 
19
my $mai_tai_store_called;
 
20
 
 
21
sub STORE {
 
22
  my ($self) = @_;
 
23
  $mai_tai_store_called = 1;
 
24
}
 
25
 
 
26
#------------------------------------------------------------------------------
 
27
 
 
28
package MyObject;
 
29
use strict;
 
30
use warnings;
 
31
use Glib;
 
32
 
 
33
use Glib::Object::Subclass
 
34
  Glib::Object::,
 
35
  properties => [ Glib::ParamSpec->int ('myprop',
 
36
                                        'myprop',
 
37
                                        'Blurb',
 
38
                                        0, 100,
 
39
                                        0,
 
40
                                        [qw/writable readable/]),
 
41
                ];
 
42
 
 
43
sub INIT_INSTANCE {
 
44
  my $self = shift;
 
45
  tie $self->{'myprop'}, 'MaiTai';
 
46
}
 
47
 
 
48
#------------------------------------------------------------------------------
 
49
 
 
50
package main;
 
51
my $obj = MyObject->new;
 
52
 
 
53
$mai_tai_store_called = 0;
 
54
$obj->set (myprop => 50);
 
55
is ($mai_tai_store_called, 1,
 
56
    'MaiTai tied store function called');
 
57
 
 
58
exit 0;