Mock::...:Object(3pm)
π Mock::...:Object β the perl manpage, but make it cute
okay bestie, so this is Mock::...:Object(3pm) from the User Contributed Perl Documentation, and it's literally the object-mocking half of Mock::Quick. sit down, hydrate, let's go β¨
πΈ NAME πΈ
Mock::Quick::Object β object mocking for Mock::Quick π
π¦ DESCRIPTION π¦
So basically this whole module is object mocking. that's the vibe. that's the whole assignment. π
but real talk β if you want a better interface, go look at Mock::Quick instead. this one's lowkey the backstage crew, not the main character. iykyk π«Ά
β¨ SYNOPSIS β¨
here's the whole vibe, no cap:
use Mock::Quick::Object;
use Mock::Quick::Method;
my $obj = Mock::Quick::Object->new(
foo => 'bar', # define attribute
do_it => qmeth { ... }, # define method
...
);
is( $obj->foo, 'bar' );
$obj->foo( 'baz' );
is( $obj->foo, 'baz' );
$obj->do_it();
# define the new attribute automatically
$obj->bar( 'xxx' );
# define a new method on the fly
$obj->baz( Mock::Quick::Method->new( sub { ... });
# remove an attribute or method
$obj->baz( \$Mock::Quick::Util::CLEAR );
okay so let's break down the drama π
- you spin up a
$objwithMock::Quick::Object->new(...)and just hand it a list of stuff. - pass a plain value like
foo => 'bar'and boom π₯ that's an attribute now. - pass
qmeth { ... }likedo_it => qmeth { ... }and boom π₯ that's a method now. - call
is( $obj->foo, 'bar' );and it slays, becausefoois'bar'. - then
$obj->foo( 'baz' );β and nowis( $obj->foo, 'baz' );passes. the attribute just got rewritten mid-argument, iconic behaviour honestly. $obj->do_it();β call your method, live your truth.$obj->bar( 'xxx' );β define the new attribute automatically β¨ it just appears. no setup. no warning. girlboss.$obj->baz( Mock::Quick::Method->new( sub { ... });β define a new method on the fly π§$obj->baz( \$Mock::Quick::Util::CLEAR );β remove an attribute or method. poof. gone. π
fr fr, those are the actual lines from the page β including the lil' dangling ); in the method one. i'm not fixing it, i'm respecting it. it's giving "authored in 2011 and we love her". π«Ά
π AUTHORS π
- Chad Granum β
exodist7@gmail.comπ
π COPYRIGHT π
- Copyright (C) 2011 Chad Granum
- Mock-Quick is free software; Standard perl licence.
- Mock-Quick is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
β οΈ bestie that warranty bit is in all caps for a reason β no promises, no guarantees, she's free software and she said what she said. π
π the cute sign-off π
and that's the whole page, periodt β¨ this was perl v5.34.0, dated 2022-06-15, and it lives its best life under Mock::...:Object(3pm). mwah π π¦ πΈ
π¦ where this page comes from
- debian bookworm: libmock-quick-perl 1.111-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmock-quick-perl 1.111-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmock-quick-perl 1.111-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmock-quick-perl 1.111-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmock-quick-perl 1.111-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms