aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-058/e-choroba/blog.txt1
-rwxr-xr-xchallenge-058/e-choroba/perl/ch-2.pl19
2 files changed, 19 insertions, 1 deletions
diff --git a/challenge-058/e-choroba/blog.txt b/challenge-058/e-choroba/blog.txt
new file mode 100644
index 0000000000..bb81d12f0b
--- /dev/null
+++ b/challenge-058/e-choroba/blog.txt
@@ -0,0 +1 @@
+http://blogs.perl.org/users/e_choroba/2020/05/perl-weekly-challenge-058-compare-version-and-ordered-lineup.html
diff --git a/challenge-058/e-choroba/perl/ch-2.pl b/challenge-058/e-choroba/perl/ch-2.pl
index f1f8ac19e8..a7c98c0e97 100755
--- a/challenge-058/e-choroba/perl/ch-2.pl
+++ b/challenge-058/e-choroba/perl/ch-2.pl
@@ -18,9 +18,26 @@ sub order {
return \@r
}
-use Test::More tests => 6;
+use Test::More tests => 21;
use Test::Exception;
+is_deeply order([1, 2, 3], [0, 0, 0]), [1, 2, 3];
+is_deeply order([1, 2, 3], [0, 1, 0]), [1, 3, 2];
+is_deeply order([1, 2, 3], [1, 0, 0]), [2, 1, 3];
+is_deeply order([1, 2, 3], [1, 1, 0]), [3, 1, 2];
+is_deeply order([1, 2, 3], [2, 0, 0]), [2, 3, 1];
+is_deeply order([1, 2, 3], [2, 1, 0]), [3, 2, 1];
+
+throws_ok { order([1, 2, 3], [0, 0, 1]) } qr/3 1/;
+throws_ok { order([1, 2, 3], [0, 1, 1]) } qr/3 1/;
+throws_ok { order([1, 2, 3], [1, 1, 1]) } qr/3 1/;
+throws_ok { order([1, 2, 3], [1, 0, 1]) } qr/3 1/;
+throws_ok { order([1, 2, 3], [2, 0, 1]) } qr/3 1/;
+throws_ok { order([1, 2, 3], [2, 1, 1]) } qr/3 1/;
+throws_ok { order([1, 2, 3], [2, 2, 1]) } qr/3 1/;
+throws_ok { order([1, 2, 3], [0, 2, 0]) } qr/2 2/;
+throws_ok { order([1, 2, 3], [2, 2, 0]) } qr/2 2/;
+
is_deeply order([2, 6, 4, 5, 1, 3],
[1, 0, 2, 0, 1, 2]),
[5, 1, 2, 6, 3, 4];