Name : perl-Test-Mock-Object
| |
Version : 0.2
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : lp154.1.1
| Date : 2023-01-27 17:39:43
|
Group : Unspecified
| Source RPM : perl-Test-Mock-Object-0.2-lp154.1.1.src.rpm
|
Size : 0.05 MB
| |
Packager : https://www_suse_com/
| |
Summary : Dead-simple mocking
|
Description :
Mock objects can be a controversial topic, but sometimes they\'re very useful. However, mock objects in Perl often come in two flavors:
* * Incomplete mocks of existing modules
* * Generic mocks with clumsy interfaces I can never remember
This module is my attempt to make things dead-easy. Here\'s a simple mock object:
my $mock = create_mock( package => \'Toy::Soldier\', methods => { name => \'Ovid\', rank => \'Private\', serial => \'123-456-789\', } );
You can figure out what that does and it\'s easy. However, we have a lot more.
Note, that while \'$mocked->isa($package)\' will return true for the name of the package you\'re mocking, but the package will be blessed into a namespace similar to \'MockMeAmadeus::$compact_package\', where \'$compact_package\' is the name of the blessed package, but with \'::\' replaced with underscores, along with a prepended \'_V$mock_number\'. Thus, mocking something into the \'Foo::Bar\' package would cause \'ref\' to return something like \'MockMeAmadeus::Foo_Bar_b1\'.
If you need something more interesting for \'isa\', pass in your own:
my $mock = create_mock( package => \'Toy::Soldier\', methods => { name => \'Ovid\', rank => \'Private\', serial => \'123-456-789\', isa => sub { my ( $self, $class ) = AATT_; return $class eq \'Toy::Soldier\' || $class eq \'Toy\'; }, } );
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-T/15.4/noarch |