Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Mocking isa under Test::Deep

by choroba (Archbishop)
on May 01, 2016 at 20:01 UTC ( #1161984=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # Old:
    cmp_deeply($obj->method, [ $result1, $result2 ]);
    # New:
    cmp_deeply($obj->method, bag($result1, $result2));
    
  2. or download this
    use warnings;
    use strict;
    ...
    
        __PACKAGE__->meta->make_immutable;
    }
    
  3. or download this
    use Test::Spec;
    describe 'position' => sub {
    ...
            cmp_deeply([ $position->person ], bag($person));
        };
    };
    
  4. or download this
    Attribute (person) does not pass the type constraint because: Validati
    +on failed for 'Person' with value Test::Spec::Mocks::MockObject={  }
    
  5. or download this
            my $person = stub( isa => 1 );
    
  6. or download this
    Found a special comparison in $data
    You can only use specials in the expects structure at /home/choroba/pe
    +rl5/lib/perl5/Test/Deep.pm line 346.
    
  7. or download this
    # Old:
    if (! $Expects and ref($d1) and UNIVERSAL::isa($d1, "Test::Deep::Cmp")
    +)
    # New:
    if (! $Expects and Scalar::Util::blessed($d1) and $d1->isa("Test::Deep
    +::Cmp"))
    
  8. or download this
            my $person = stub( isa => sub { $_[1] !~ /Test/ } );
    
  9. or download this
    sub mock_isa { my ($class) = @_; isa => sub { $_[1] eq $class } }
    
  10. or download this
            my $person = stub(mock_isa('Person'));
    
  11. or download this
    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord
    }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://1161984]
Approved by hippo
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2020-01-20 21:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?