From: Shawn M Moore Date: Tue, 10 Jun 2008 02:44:37 +0000 (+0000) Subject: Make sure that eager builder does not run after clearer X-Git-Tag: 0.04~66 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=010a2b16f8ed60a3dcca43e80ec75daee135447e;p=gitmo%2FMouse.git Make sure that eager builder does not run after clearer --- diff --git a/t/023-builder.t b/t/023-builder.t index a89ee0b..25b7fa8 100644 --- a/t/023-builder.t +++ b/t/023-builder.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 30; +use Test::More tests => 34; my $builder_called = 0; my $lazy_builder_called = 0; @@ -15,6 +15,7 @@ do { isa => 'Str', builder => '_build_name', predicate => 'has_name', + clearer => 'clear_name', ); sub _build_name { @@ -51,6 +52,13 @@ is($object->name, "Bill", "builder doesn't matter when we just set the value in is($builder_called, 0, "builder not called in the setter"); $builder_called = 0; +$object->clear_name; +ok(!$object->has_name, "predicate: no value after clear"); +is($object->name, undef, "eager builder does NOT swoop in after clear"); +ok(!$object->has_name, "predicate: no value after clear and get"); +is($builder_called, 0, "builder not called in the getter, even after clear"); +$builder_called = 0; + my $object2 = Class->new; ok($object2->has_name, "predicate: value from eager builder"); is($object2->name, "FRANK", "builder called to provide the default value");