Glib

 view release on metacpan or  search on metacpan

t/4.t  view on Meta::CPAN

#!/usr/bin/perl
#
# test Glib::Object derivation in Perl.
# derive from a C object in perl, and derive from a Perl object in perl.
# checks order of execution of initializers and finalizers, so the code
# gets a little hairy.
#
use strict;
use warnings;

use Glib qw(:constants);

# From 7.t.  Do we need a test helper class?
sub ok($$;$) {
    my($test, $num, $name) = @_;

    my $out = $test ? "ok" : "not ok";
    $out .= " $num" if $num;
    $out .= " - $name" if defined $name;

    print "$out\n";

    return $test;
}

sub pass($;$) {
    my($num, $name) = @_;
    return ok(1, $num, $name);
}

sub fail(;$) {
    my($name) = @_;
    return ok(0, 0, $name);
}

print "1..17\n";
pass 1;

my $init_self;

sub Foo::INIT_INSTANCE {
   $init_self = $_[0]*1;
   pass 2, 'Foo::INIT_INSTANCE';
}

sub Foo::FINALIZE_INSTANCE {
   pass 9, 'Foo::FINALIZE_INSTANCE'
}

my $setprop_self;

sub Foo::SET_PROPERTY {
   $setprop_self = $_[0]*1;
   pass $_[2], 'Foo::SET_PROPERTY';
}

sub Foo::GET_PROPERTY {
   pass 6, 'Foo::GET_PROPERTY';
   6;
}

Glib::Type->register (
   Glib::Object::, Foo::,
   properties => [
           Glib::ParamSpec->string (
              'some_string',
              'Some String Property',
              'This property is a string that is used as an example',
              'default value',
              [qw/readable writable/]
           ),
   ]);

sub Bar::INIT_INSTANCE {



( run in 0.804 second using v1.01-cache-2.11-cpan-b16cb0d3907 )