Skip to content

Commit

Permalink
Give all exercises same directory structure (exercism#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-dango authored Sep 28, 2023
1 parent 005cb11 commit 270b688
Show file tree
Hide file tree
Showing 368 changed files with 369 additions and 395 deletions.
6 changes: 3 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
},
"files": {
"solution": [
"%{pascal_slug}.pm",
"lib/%{pascal_slug}.pm",
"cpanfile",
"vendor/cache/modules/02packages.details.txt.gz"
],
"test": [
"%{kebab_slug}.t"
"t/%{kebab_slug}.t"
],
"example": [
".meta/solutions/%{pascal_slug}.pm",
".meta/solutions/lib/%{pascal_slug}.pm",
".meta/solutions/cpanfile",
".meta/solutions/vendor/cache/modules/02packages.details.txt.gz"
],
Expand Down
36 changes: 14 additions & 22 deletions docs/TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,46 @@

## Run All Tests

There is a Perl script with the extension `.t`, which will be used to test
your solution. You can run through the tests by using the command:
There is a Perl script with the extension `.t` contained in the `t/` directory, which will be used to testyour solution.
You can run through the tests by using the command:

`prove .`
`prove`

Before you start the exercise, the output will likely look something like:

```
./hello-world.t .. 1/2
./t/hello-world.t .. 1/2
# Failed test 'Say Hi!'
# at exercises/hello-world/hello-world.t line 15.
# at exercises/hello-world/t/hello-world.t line 15.
# +---------+---------------+
# | GOT | CHECK |
# +---------+---------------+
# | <UNDEF> | Hello, World! |
# +---------+---------------+
exercises/hello-world/hello-world.t .. Dubious, test returned 1 (wstat 256, 0x100)
exercises/hello-world/t/hello-world.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/2 subtests
Test Summary Report
-------------------
./hello-world.t (Wstat: 256 Tests: 2 Failed: 1)
./t/hello-world.t (Wstat: 256 Tests: 2 Failed: 1)
Failed test: 2
Non-zero exit status: 1
Files=1, Tests=2, 0 wallclock secs ( 0.03 usr 0.00 sys + 0.18 cusr 0.02 csys = 0.23 CPU)
Result: FAIL
```

You will either need to modify or create a module with the extension `.pm`, and
write a solution to pass the tests. Once the tests are passing, the output from
the command above will likely look something like:
You will need to modify the module with the extension `.pm`, contained in the `lib/` directory, and write a solution to pass the tests.
Once the tests are passing, the output from the command above will likely look something like:

```
./hello-world.t .. ok
./t/hello-world.t .. ok
All tests successful.
Files=1, Tests=2, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.07 cusr 0.01 csys = 0.10 CPU)
Result: PASS
```

Some exercises may have optional tests. You can test for these by adding the
flag `-v` (for 'verbose') to the above command, like so:
Documentation about the assertions used in the test files can be found in [Test2::Manual::Testing::Introduction][test2-manual].
You can find a more in-depth explanation of `Test2` on [perldoc][test2].

`prove . -v`

As well as showing optional tests, it will include all of the tests that
your solution currently passes.

Documentation about the assertions used in the test files can be found in
[Test2::Manual::Testing::Introduction](https://metacpan.org/pod/Test2::Manual::Testing::Introduction).
You can find a more in-depth explanation of `Test2` on
[perldoc](https://perldoc.pl/Test2).
[test2-manual]: https://metacpan.org/pod/Test2::Manual::Testing::Introduction
[test2]: https://perldoc.pl/Test2
28 changes: 14 additions & 14 deletions exercises/concept/booking-up-for-beauty/.meta/config.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"blurb": "Learn about importing and exporting modules in Perl by building an appointment scheduler for a beauty salon.",
"authors": [
"m-dango"
"authors": [
"m-dango"
],
"files": {
"solution": [
"lib/BookingUpForBeauty.pm"
],
"files": {
"solution": [
"lib/BookingUpForBeauty.pm"
],
"test": [
"t/booking-up-for-beauty.t"
],
"exemplar": [
".meta/BookingUpForBeauty.pm"
]
}
"test": [
"t/booking-up-for-beauty.t"
],
"exemplar": [
".meta/BookingUpForBeauty.pm"
]
},
"blurb": "Learn about importing and exporting modules in Perl by building an appointment scheduler for a beauty salon."
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/env perl

use v5.38;
use Test2::V0;

use Time::Piece;
use Time::Seconds;

use FindBin qw<$Bin>;
use lib "$Bin/../lib", "$Bin/../local/lib/perl5";

use BookingUpForBeauty qw<
appointment_has_passed
is_afternoon_appointment
Expand Down
4 changes: 3 additions & 1 deletion exercises/concept/high-score-board/t/high-score-board.t
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env perl

use v5.38;
use Test2::V0;

use FindBin qw<$Bin>;
use lib "$Bin/../lib", "$Bin/../local/lib/perl5";

use HighScoreBoard ();

subtest 'set_player_scores(%new_scores)' => sub { # begin: set task: 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env perl

use v5.38;
use Test2::V0;

use FindBin qw<$Bin>;
use lib "$Bin/../lib", "$Bin/../local/lib/perl5";

use InventoryManagement ();

subtest 'create_inventory($items)' => sub { # begin: create task: 1
Expand Down
4 changes: 3 additions & 1 deletion exercises/concept/language-list/t/language-list.t
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env perl

use v5.38;
use Test2::V0;

use FindBin qw<$Bin>;
use lib "$Bin/../lib", "$Bin/../local/lib/perl5";

use LanguageList ();

subtest 'add_language()' => sub { # begin: add_language task: 1
Expand Down
4 changes: 3 additions & 1 deletion exercises/concept/lasagna/t/lasagna.t
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env perl

use v5.38;
use Test2::V0;

use FindBin qw<$Bin>;
use lib "$Bin/../lib", "$Bin/../local/lib/perl5";

use Lasagna ();

is( # begin: var task: 1
Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/accumulate/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
],
"files": {
"solution": [
"Accumulate.pm"
"lib/Accumulate.pm"
],
"test": [
"accumulate.t"
"t/accumulate.t"
],
"example": [
".meta/solutions/Accumulate.pm"
".meta/solutions/lib/Accumulate.pm"
]
},
"blurb": "Implement the `accumulate` operation, which, given a collection and an operation to perform on each element of the collection, returns a new collection containing the result of applying that operation to each element of the input collection.",
Expand Down
1 change: 0 additions & 1 deletion exercises/practice/accumulate/.meta/solutions/accumulate.t

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use Test2::V0;

use FindBin qw<$Bin>;
use lib $Bin, "$Bin/local/lib/perl5";
use lib "$Bin/../lib", "$Bin/../local/lib/perl5";

use Accumulate qw<accumulate>;
use experimental qw<signatures>;
Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/all-your-base/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
],
"files": {
"solution": [
"AllYourBase.pm"
"lib/AllYourBase.pm"
],
"test": [
"all-your-base.t"
"t/all-your-base.t"
],
"example": [
".meta/solutions/AllYourBase.pm"
".meta/solutions/lib/AllYourBase.pm"
]
},
"blurb": "Convert a number, represented as a sequence of digits in one base, to any other base."
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use Test2::V0;

use FindBin qw<$Bin>;
use lib $Bin, "$Bin/local/lib/perl5";
use lib "$Bin/../lib", "$Bin/../local/lib/perl5";

use AllYourBase qw<rebase>;

Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/allergies/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
],
"files": {
"solution": [
"Allergies.pm"
"lib/Allergies.pm"
],
"test": [
"allergies.t"
"t/allergies.t"
],
"example": [
".meta/solutions/Allergies.pm"
".meta/solutions/lib/Allergies.pm"
]
},
"blurb": "Given a person's allergy score, determine whether or not they're allergic to a given item, and their full list of allergies.",
Expand Down
1 change: 0 additions & 1 deletion exercises/practice/allergies/.meta/solutions/allergies.t

This file was deleted.

1 change: 1 addition & 0 deletions exercises/practice/allergies/.meta/solutions/t/allergies.t
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use Test2::V0;

use FindBin qw<$Bin>;
use lib $Bin, "$Bin/local/lib/perl5";
use lib "$Bin/../lib", "$Bin/../local/lib/perl5";

use Allergies qw<allergic_to list_allergies>;

Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/anagram/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
],
"files": {
"solution": [
"Anagram.pm"
"lib/Anagram.pm"
],
"test": [
"anagram.t"
"t/anagram.t"
],
"example": [
".meta/solutions/Anagram.pm"
".meta/solutions/lib/Anagram.pm"
]
},
"blurb": "Given a word and a list of possible anagrams, select the correct sublist.",
Expand Down
1 change: 0 additions & 1 deletion exercises/practice/anagram/.meta/solutions/anagram.t

This file was deleted.

1 change: 1 addition & 0 deletions exercises/practice/anagram/.meta/solutions/t/anagram.t
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use Test2::V0;

use FindBin qw<$Bin>;
use lib $Bin, "$Bin/local/lib/perl5";
use lib "$Bin/../lib", "$Bin/../local/lib/perl5";

use Anagram qw<match_anagrams>;

Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/atbash-cipher/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
],
"files": {
"solution": [
"AtbashCipher.pm"
"lib/AtbashCipher.pm"
],
"test": [
"atbash-cipher.t"
"t/atbash-cipher.t"
],
"example": [
".meta/solutions/AtbashCipher.pm"
".meta/solutions/lib/AtbashCipher.pm"
]
},
"blurb": "Create an implementation of the atbash cipher, an ancient encryption system created in the Middle East.",
Expand Down
31 changes: 0 additions & 31 deletions exercises/practice/atbash-cipher/.meta/solutions/Cipher.pm

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use Test2::V0;

use FindBin qw<$Bin>;
use lib $Bin, "$Bin/local/lib/perl5";
use lib "$Bin/../lib", "$Bin/../local/lib/perl5";

use AtbashCipher qw<encode_atbash decode_atbash>;

Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/binary-search-tree/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
],
"files": {
"solution": [
"BinarySearchTree.pm"
"lib/BinarySearchTree.pm"
],
"test": [
"binary-search-tree.t"
"t/binary-search-tree.t"
],
"example": [
".meta/solutions/BinarySearchTree.pm"
".meta/solutions/lib/BinarySearchTree.pm"
]
},
"blurb": "Insert and search for numbers in a binary tree.",
Expand Down

This file was deleted.

Loading

0 comments on commit 270b688

Please sign in to comment.