aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2020-05-04 00:27:54 +0100
committerGitHub <noreply@github.com>2020-05-04 00:27:54 +0100
commitdca4f1992b1f30281b11ee43598fb30f66851175 (patch)
treea2268e160c41014af0afeca5a710ed85fa90de11
parent0daa3d92ce3c4cb6c4662b528ab82cbe52ae50f6 (diff)
parent4ddcf09f3fc24af49e61a81a55208412c3ab97ca (diff)
downloadperlweeklychallenge-club-dca4f1992b1f30281b11ee43598fb30f66851175.tar.gz
perlweeklychallenge-club-dca4f1992b1f30281b11ee43598fb30f66851175.tar.bz2
perlweeklychallenge-club-dca4f1992b1f30281b11ee43598fb30f66851175.zip
Merge pull request #1663 from choroba/ech058b
Add a 058 blog post by E. Choroba (Compare Version & Ordered Lineup)
-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];