File: 12_prio.t

package info (click to toggle)
libobject-event-perl 1.230-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 240 kB
  • sloc: perl: 1,099; makefile: 8
file content (31 lines) | stat: -rw-r--r-- 721 bytes parent folder | download | duplicates (3)
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
#!perl

use Test::More tests => 1;

package foo;
use common::sense;

use Object::Event;
$Object::Event::ENABLE_METHODS_DEFAULT = $ENV{OE_METHODS_ENABLE};

our @ISA = qw/Object::Event/;

package main;
use common::sense;

# obfuscation around update_test
my $oe = 'Object' . '::' . 'Event';
&{$oe. '::' . 'register_priority_alias'} ('first', 3000);
&{$oe. '::' . 'register_priority_alias'} ('last', -3000);

my $f = foo->new;

$f->reg_cb (
   first_test  => sub { push @{$f->{r}}, 1 },
   before_test => sub { push @{$f->{r}}, 2 },
   test        => sub { push @{$f->{r}}, 3 },
   last_test   => sub { push @{$f->{r}}, 4 },
);

$f->event ('test');
is (join (',', @{$f->{r}}), '1,2,3,4', 'all callbacks got correct order');