aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorE. Choroba <choroba@matfyz.cz>2020-05-04 00:44:26 +0200
committerE. Choroba <choroba@matfyz.cz>2020-05-04 00:44:26 +0200
commit4ddcf09f3fc24af49e61a81a55208412c3ab97ca (patch)
treeab7ca47afb99c95934879803d681280d0113ee80
parent068dd9fc3486625d78923a8919eb220147f8a387 (diff)
downloadperlweeklychallenge-club-4ddcf09f3fc24af49e61a81a55208412c3ab97ca.tar.gz
perlweeklychallenge-club-4ddcf09f3fc24af49e61a81a55208412c3ab97ca.tar.bz2
perlweeklychallenge-club-4ddcf09f3fc24af49e61a81a55208412c3ab97ca.zip
Add a 058 blog post by E. Choroba (Compare Version & Ordered Lineup)
Also, add more test cases to 058/1.
-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];