http://qs321.pair.com?node_id=11142249


in reply to Re: I have finally done it; wrote a Tesla API library for Perl!
in thread I have finally done it; wrote a Tesla API library for Perl!

I wrote Mock::Sub several years ago, apparently waiting for this exact problem!

use warnings; use strict; use feature 'say'; use Mock::Sub; use Tesla::Vehicle; my $mock = Mock::Sub->new; my $car = Tesla::Vehicle->new; my $speed_sub = $mock->mock('Tesla::Vehicle::speed'); $speed_sub->return_value(60); # No matter how fast I'm going, we'll always return 60! say $car->speed;

Replies are listed 'Best First'.
Re^3: I have finally done it; wrote a Tesla API library for Perl!
by perldigious (Priest) on Mar 21, 2022 at 17:22 UTC

    In that instance was it best designated as Mock::Sub, or should it have been designated Mock::HighwayPatrol? :-)

    Just another Perl hooker - My clients appreciate that I keep my code clean but my comments dirty.