1use strict; 2use Test::More tests => 3; 3 4use IO::Scalar; 5 6use lib 't/lib'; 7use Foo; 8 9ok(Foo->add_trigger(foo => sub { print "foo: $_[1]\n" }), 10 'add_trigger in Foo'); 11 12{ 13 my $foo = Foo->new; 14 tie *STDOUT, 'IO::Scalar', \my $out; 15 $foo->call_trigger(foo => 1); 16 is $out, "foo: 1\n"; 17} 18{ 19 20 tie *STDOUT, 'IO::Scalar', \my $out; 21 Foo->call_trigger(foo => 2); 22 is $out, "foo: 2\n"; 23} 24 25