File: 01trigger.t

package info (click to toggle)
libobject-pad-fieldattr-trigger-perl 0.07-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 120 kB
  • sloc: perl: 44; makefile: 3
file content (28 lines) | stat: -rw-r--r-- 408 bytes parent folder | download
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
#!/usr/bin/perl

use v5.14;
use warnings;

use Test2::V0;

use Object::Pad;
use Object::Pad::FieldAttr::Trigger;

my @triggered;

class Example
{
   field $value :reader :writer :Trigger(trig);

   method trig { push @triggered, $value; }
}

my $obj = Example->new;

$obj->set_value( 123 );
$obj->set_value( 456 );

is( \@triggered, [ 123, 456 ],
   'Trigger method invoked by ->set_value' );

done_testing;