Gen::T...Result(3pm)
π Gen::Test::Rinci::FuncResult π
okay so bestie, this page is the manual for Gen::Test::Rinci::FuncResult (yes the terminal chops it down to Gen::T...Result(3pm), that's just the header being dramatic) β and it's about generating a test function for a function. iykyk. πΈ
β¨ VERSION β¨
This document describes version 0.06 of Gen::Test::Rinci::FuncResult (from Perl distribution Gen-Test-Rinci-FuncResult), released on 2017-07-11. she's a little vintage, she's still iconic. π
π SYNOPSIS π
use Gen::Test::Rinci::FuncResult qw(gen_test_func);
use Test::More;
sub divide {
my %args = @_;
my ($a, $b) = ($args{a}, $args{b});
return [500, "undefined"] if $a == 0 && $b == 0;
[200, "OK", $a/$b];
}
gen_test_func(name => 'test_divide', func => \÷);
test_divide(args=>{a=>6, b=>3}, result=>2);
test_divide(args=>{a=>6, b=>0}, dies=>1);
test_divide(args=>{a=>0, b=>0}, status=>500);
done_testing;
like⦠look at her go. ⨠you write ONE test-generator call and then you just keep calling the generated function with vibes and args. obsessed.
π DESCRIPTION π
ngl the original page leaves this section completely empty β no cap, there's literally nothing here before FUNCTIONS starts. so consider this the aesthetic whitespace moment of the manpage. π¦ the actual tea is right below. π
π₯ FUNCTIONS π₯
π gen_test_func
Usage:
gen_test_func(%args) -> [status, msg, result, meta]
Generate a test function for a function.
okay so here's the lore, bestie: this function (let's call her A) will generate a function (let's call her B). it's giving meta. it's giving function factory. π
A accepts, among others, the name or the reference to the function that you want to test (T) and the name of the generated function, B.
B will run T once with some specified arguments, catch exception, and test its result. The result is expected to be an enveloped result (see the documentation of "Rinci::function" for more details about enveloped result). π«Ά
B will accept the following arguments:
name(str)
Name of the test. Will default to "T (ARGS...)" to show the name of the target function and the arguments that it is called with.
args(hash or array)
Argument to feed to function T.
dies(bool, default => 0)
Whether function T should die when run. If set to 1, further tests will not be done except the test that function dies.
status(int, default => 200)
Will test the result's status code.
result(any)
If specified, will test the actual result of the function.
run(code)
Instead of running function T with "args", will execute this code instead.
posttest(code)
Run this code for additional tests.
Todo:
- Handle function with
"result_naked" => 1.
This function is not exported by default, but exportable. (so yes bestie, you do have to ask for her by name. π)
Arguments ('*' denotes required arguments):
func*=>codeβ Target function to test.install=>bool(default: 1) β Whether to install the function.name*=>strβ Name of the test function to generate (B). Can be fully qualified, e.g."Pkg::SubPkg::funcname"or unqualified"funcname"(where the package will be taken from the"package"argument). Relevant for when installing the function.package=>anyβ Perl package to put this function in. Relevant only when installing the function.
Returns an enveloped result (an array). π
First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.
Return value: (any)
π§ FAQ π§
okay so this section is empty in the original β no questions, no answers, just vibes. πΈ she said "ask me nothing." iconic behaviour honestly.
π HOMEPAGE π
Please visit the project's homepage at <https://metacpan.org/release/Gen-Test-Rinci-FuncResult>.
π¦ SOURCE π¦
Source repository is at <https://github.com/perlancar/perl-Gen-Test-Rinci-FuncResult>.
π BUGS π
Please report any bugs or feature requests on the bugtracker website <https://rt.cpan.org/Public/Dist/Display.html?Name=Gen-Test-Rinci-FuncResult>
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. (fr fr, a failing test is worth a thousand "it doesn't work" messages. π«Ά)
π SEE ALSO π
Rinci
π AUTHOR π
perlancar <perlancar@cpan.org>
βοΈ COPYRIGHT AND LICENSE βοΈ
This software is copyright (c) 2017, 2015, 2014, 2013 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
and that's the whole page, bestie!! π this one came to you courtesy of perl v5.34.0 and it was last touched on 2022-06-14 β go forth and generate some test functions, you absolute main character. πβ¨π¦
π¦ where this page comes from
- debian bookworm: libgen-test-rinci-funcresult-perl 0.06-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libgen-test-rinci-funcresult-perl 0.06-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libgen-test-rinci-funcresult-perl 0.06-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libgen-test-rinci-funcresult-perl 0.06-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libgen-test-rinci-funcresult-perl 0.06-1 Β· 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