do not ship this content again!
[gitmo/MooseX-UndefTolerant.git] / t / lib / ConstructorTests.pm
index 340e2f7..3174157 100644 (file)
@@ -56,7 +56,8 @@ use Test::Fatal;
 
 sub do_tests
 {
-    note 'Testing class with a single UndefTolerant attribute';
+    note 'Testing ', (Foo->meta->is_immutable ? 'im' : '') . 'mutable ',
+        'class with a single UndefTolerant attribute';
     {
         my $obj = Foo->new;
         ok(!$obj->has_attr1, 'attr1 has no value before it is assigned');
@@ -69,7 +70,6 @@ sub do_tests
         $TODO = 'some immutable cases are not handled yet; see CAVEATS' if Foo->meta->is_immutable;
         is(
             exception {
-
                 my $obj = Foo->new(attr1 => undef);
                 ok(!$obj->has_attr1, 'UT attr1 has no value when assigned undef in constructor');
                 like(
@@ -79,10 +79,12 @@ sub do_tests
 
                 is (exception { $obj = Foo->new(attr3 => undef) }, undef,
                     'assigning undef to attr3 is acceptable');
-                ok($obj->has_attr3, 'attr3 retains its undef value when assigned undef in constructor');
+                ok($obj->has_attr3, 'attr3 still has a value');
+                is($obj->attr3, undef, '...which is undef, when assigned undef in constructor');
             },
             undef,
-            'successfully tested spot-applicaction of UT trait in immutable classes',
+            'successfully tested spot-application of UT trait in '
+                . (Foo->meta->is_immutable ? 'im' : '') . 'mutable classes',
         );
     }
 
@@ -98,9 +100,10 @@ sub do_tests
         ok($obj->has_attr3, '...and the predicate returns true as normal');
     }
 
-
     note '';
-    note 'Testing class with the entire class being UndefTolerant';
+    note 'Testing class with the entire ',
+        (Bar->meta->is_immutable ? 'im' : '') . 'mutable ',
+        'class being UndefTolerant';
     {
         my $obj = Bar->new;
         ok(!$obj->has_attr1, 'attr1 has no value before it is assigned');
@@ -116,9 +119,10 @@ sub do_tests
             'assigning undef to attr2 does not produce an error');
         ok(!$obj->has_attr2, 'attr2 has no value when assigned undef in constructor');
 
-        is( exception { $obj = Foo->new(attr3 => undef) }, undef,
+        is( exception { $obj = Bar->new(attr3 => undef) }, undef,
             'assigning undef to attr3 is acceptable');
-        ok($obj->has_attr3, 'attr3 retains its undef value when assigned undef in constructor');
+        ok($obj->has_attr3, 'attr3 still has a value');
+        is($obj->attr3, undef, '...which is undef, when assigned undef in constructor');
     }
 
     {