From: Graham Knop Date: Wed, 17 Apr 2013 07:16:39 +0000 (-0400) Subject: failing test for isa being called on already built values X-Git-Tag: v1.002000~28 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f9428f9c6a4bace160f1886150c080c0ebe24752;p=gitmo%2FMoo.git failing test for isa being called on already built values --- diff --git a/t/lazy_isa.t b/t/lazy_isa.t index 10b286f..7ac5ff9 100644 --- a/t/lazy_isa.t +++ b/t/lazy_isa.t @@ -2,12 +2,16 @@ use strictures 1; use Test::More; use Test::Fatal; +my $isa_called = 0; { package FooISA; use Moo; - my $isa = sub { die "I want to die" unless $_[0] eq 'live' }; + my $isa = sub { + $isa_called++; + die "I want to die" unless $_[0] eq 'live'; + }; has a_lazy_attr => ( is => 'ro', @@ -28,6 +32,10 @@ use Test::Fatal; ok my $lives = FooISA->new(a_lazy_attr=>'live', non_lazy=>'live'), 'expect to live when both attrs are set to live in init'; +my $called_pre = $isa_called; +$lives->a_lazy_attr; +is $called_pre, $isa_called, 'isa is not called on access when value already exists'; + like( exception { FooISA->new(a_lazy_attr=>'live', non_lazy=>'die') }, qr/I want to die/,