evgenyigumnov / rustsn

Code snippets generator via LLMs and compiler/tester via build tools
GNU General Public License v3.0
18 stars 5 forks source link

Add Perl support #17

Open evgenyigumnov opened 2 days ago

evgenyigumnov commented 2 days ago

Launch example

rustsn --lang=perl

Example query:

take 2 params and add them and return result

Example generation:

Makefile.PL

use ExtUtils::MakeMaker;

WriteMakefile(
    NAME         => 'Solution',
    VERSION_FROM => 'lib/Solution.pm', # finds $VERSION
    AUTHOR       => 'Your Name <you@example.com>',
    ABSTRACT     => 'Minimalistic Perl project',
    TESTS         => 't/*.t',
    PREREQ_PM    => {
        'Test::More' => 0,
    },
);

lib/Solution.pm

package Solution;
use strict;
use warnings;
use Exporter 'import';
our @EXPORT_OK = ('add');

sub add {
    my ($a, $b) = @_;
    return $a + $b;
}

1;

t/solution.t

use strict;
use warnings;
use Test::More tests => 3;
use Solution qw(add);

is(add(1, 2), 3, 'add(1, 2) should return 3');
is(add(-1, -2), -3, 'add(-1, -2) should return -3');
is(add('1', 2), '12', 'add("1", 2) should return "12"');

Example install dependencies and build

perl Makefile.PL
make
make test
make install

Example launch test

prove -l t/