File: boxed_errors.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 (38 lines) | stat: -rw-r--r-- 760 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/perl

# Test the GBoxed wrapper for GError.

use strict;
use warnings;
use Test::More;
use Glib ':constants';

if (Glib->CHECK_VERSION (2, 26, 0)) {
  plan tests => 5;
} else {
  plan skip_all => 'new in 2.26';
}

Glib::Type->register_object (
  'Glib::Object',
  'Foo',
  signals => {
    throw => {
      param_types => [qw(Glib::Error)],
    },
  },
);

my $foo = Glib::Object::new ('Foo');
$foo->signal_connect (throw => \&throw_handler, 23);
$foo->signal_emit ('throw', Glib::File::Error->new ('io', 'End of file reached'));

sub throw_handler {
  my ($instance, $error, $data) = @_;
  is ($instance, $foo);
  is ($data, 23);

  isa_ok ($error, 'Glib::File::Error');
  is ($error->value, 'io');
  is ($error->message, 'End of file reached');
}