File: tied_set_property.t

package info (click to toggle)
libglib-perl 3%3A1.329-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,320 kB
  • sloc: perl: 4,938; ansic: 901; makefile: 7
file content (58 lines) | stat: -rw-r--r-- 1,205 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/perl

package main;
use strict;
use warnings;
use Test::More tests => 1;

#------------------------------------------------------------------------------

package MaiTai;
use strict;
use warnings;

sub TIESCALAR {
  my ($class) = @_;
  return bless {}, $class;
}

my $mai_tai_store_called;

sub STORE {
  my ($self) = @_;
  $mai_tai_store_called = 1;
}

#------------------------------------------------------------------------------

package MyObject;
use strict;
use warnings;
use Glib;

use Glib::Object::Subclass
  Glib::Object::,
  properties => [ Glib::ParamSpec->int ('myprop',
                                        'myprop',
                                        'Blurb',
                                        0, 100,
                                        0,
                                        [qw/writable readable/]),
                ];

sub INIT_INSTANCE {
  my $self = shift;
  tie $self->{'myprop'}, 'MaiTai';
}

#------------------------------------------------------------------------------

package main;
my $obj = MyObject->new;

$mai_tai_store_called = 0;
$obj->set (myprop => 50);
is ($mai_tai_store_called, 1,
    'MaiTai tied store function called');

exit 0;