aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2020-05-04 00:28:51 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2020-05-04 00:28:51 +0100
commit67ca3b7f081bf0305ef3f2a7abbfbb2d7370f8a6 (patch)
tree88dd1ecaf85a4c40ea0cb7fb0742d5a1c0766549
parentda2924d27e1156b39d978e74b33f2a88ea95249a (diff)
parentdca4f1992b1f30281b11ee43598fb30f66851175 (diff)
downloadperlweeklychallenge-club-67ca3b7f081bf0305ef3f2a7abbfbb2d7370f8a6.tar.gz
perlweeklychallenge-club-67ca3b7f081bf0305ef3f2a7abbfbb2d7370f8a6.tar.bz2
perlweeklychallenge-club-67ca3b7f081bf0305ef3f2a7abbfbb2d7370f8a6.zip
Merge branch 'master' of https://github.com/manwar/perlweeklychallenge-club
-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];