From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

#!/usr/bin/perl
use strict;
our $CLASS;
BEGIN {
$CLASS = 'Mock::Quick::Method';
use_ok($CLASS);
}
tests create => sub {
my $code = sub { 1 };
my $obj = $CLASS->new($code);
isa_ok( $obj, $CLASS );
is( $CLASS->new($code), $obj, "Building a method with the same sub twice succeeds" );
};
tests error => sub {
throws_ok { $CLASS->new("foo") } qr/Constructor to $CLASS takes a single codeblock/, "Must be created with codeblock";
};
run_tests;
done_testing;