File: extends-fields.t

package info (click to toggle)
libtest-mockobject-perl 1.20200122-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 216 kB
  • sloc: perl: 1,260; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 543 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env perl

use Test::More;
use Test::Exception;
use Test::MockObject::Extends;

package MyModule;

use strict;
use warnings;

use fields qw(field1 field2);

sub new
{
    my $self = shift;
    $self    = fields::new($self) unless ref $self;
    return $self;
}

package main;

use Test::MockObject::Extends;
my $fieldy = MyModule->new;
isa_ok $fieldy, 'MyModule';

my $mocky;
lives_ok { $mocky = Test::MockObject::Extends->new( $fieldy ) }
    'fields-based object should be mockstensible';
isa_ok $mocky, 'MyModule';

done_testing;