From 4ddcf09f3fc24af49e61a81a55208412c3ab97ca Mon Sep 17 00:00:00 2001 From: "E. Choroba" Date: Mon, 4 May 2020 00:44:26 +0200 Subject: Add a 058 blog post by E. Choroba (Compare Version & Ordered Lineup) Also, add more test cases to 058/1. --- challenge-058/e-choroba/blog.txt | 1 + challenge-058/e-choroba/perl/ch-2.pl | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 challenge-058/e-choroba/blog.txt 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]; -- cgit