From 03d66b78fd33f9484d2fd161f2130b69fffd4d0d Mon Sep 17 00:00:00 2001 From: Jörg Sommrey <28217714+jo-37@users.noreply.github.com> Date: Tue, 18 Jul 2023 14:35:04 +0200 Subject: Solution to task 2 --- challenge-226/jo-37/perl/ch-2.pl | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 challenge-226/jo-37/perl/ch-2.pl diff --git a/challenge-226/jo-37/perl/ch-2.pl b/challenge-226/jo-37/perl/ch-2.pl new file mode 100755 index 0000000000..8a621bd7ff --- /dev/null +++ b/challenge-226/jo-37/perl/ch-2.pl @@ -0,0 +1,59 @@ +#!/usr/bin/perl -s + +use v5.24; +use Test2::V0; + +our ($tests, $examples); + +run_tests() if $tests || $examples; # does not return + +die <@{@_} = (); + scalar grep $_, keys %v; +} + + +### Examples and tests + +sub run_tests { + SKIP: { + skip "examples" unless $examples; + + is zero_array(1, 5, 0, 3, 5), 3, 'example 1'; + is zero_array(0), 0, 'example 2'; + is zero_array(2, 1, 4, 0, 3), 4, 'example 3'; + } + + SKIP: { + skip "tests" unless $tests; + + is zero_array(1, 2, 1, 2), 2, 'no zero'; + } + + done_testing; + exit; +} -- cgit