Skip to content

Commit

Permalink
Create directories for exercises (#679)
Browse files Browse the repository at this point in the history
* Create directories for exercises
* Restore binary and trinary
* Update testing docs
  • Loading branch information
m-dango authored Jan 28, 2024
1 parent 0565d2b commit be2dfe4
Show file tree
Hide file tree
Showing 427 changed files with 439 additions and 418 deletions.
6 changes: 3 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
"checklist_issue": 30,
"files": {
"solution": [
"%{pascal_slug}.rakumod"
"lib/%{pascal_slug}.rakumod"
],
"test": [
"%{kebab_slug}.rakutest"
"t/%{kebab_slug}.rakutest"
],
"example": [
".meta/solutions/%{pascal_slug}.rakumod"
".meta/solutions/lib/%{pascal_slug}.rakumod"
],
"exemplar": [
".meta/%{pascal_slug}.rakumod"
Expand Down
43 changes: 18 additions & 25 deletions docs/TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,28 @@
## Run All Tests

There is a Raku script with the extension `.rakutest`, which will be used to test your solution.
You can run through the tests by using either of these commands (replacing the exercise name where relevant):
You can run through the tests by using the command:

If the test is in the `t/` directory:
`prove6 --lib`

If the test is in the top-level directory:
`prove6 hello-world.rakutest`
`prove6`

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

```
# Failed test 'Say Hi!'
# at hello-world.rakutest line 11
# expected: 'Hello, World!'
# got: (Nil)
# Looks like you failed 1 test of 1
hello-world.rakutest .. Dubious, test returned 1
# at t/hello-world.rakutest line 6
# expected: "Hello, World!"
# matcher: 'infix:<eq>'
# got: "Goodbye, Mars!"
# You failed 1 test of 1
t/hello-world.rakutest ... Dubious, test returned 1
Failed 1/1 subtests
```
You will need to modify the module with the extension `.rakumod`, 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 `.rakumod`, 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.rakutest .. ok
t/hello-world.rakutest ... ok
All tests successful.
```

Expand All @@ -42,19 +38,19 @@ In Linux / OS X:
```bash
export RAKU_TEST_DIE_ON_FAIL=1
# now all the follow up runs will stop at the first failure
prove6 hello-world.rakutest
prove6
# until we do
unset RAKU_TEST_DIE_ON_FAIL
# or you can use it for one run like this:
RAKU_TEST_DIE_ON_FAIL=1 prove6 hello-world.rakutest
RAKU_TEST_DIE_ON_FAIL=1 prove6
```

Or in Windows:

```
SET RAKU_TEST_DIE_ON_FAIL=1
REM now all the follow up runs will stop at the first failure
prove6 hello-world.rakutest
prove6
REM until we do
set RAKU_TEST_DIE_ON_FAIL=
```
Expand All @@ -69,9 +65,6 @@ For more information see the
Could not find JSON::Fast
```

All modules used in the Raku track are included with Rakudo Star. If you get an
error message such as the above when attempting to run a test, then you will either
need to make sure you have the latest distribution of Rakudo Star, or install the
module yourself using a package manager. See the
[Raku documentation on modules](https://docs.raku.org/language/modules#Looking_for_and_installing_modules.)
for information on how to install modules.
All modules used in the Raku track are included with Rakudo Star.
If you get an error message such as the above when attempting to run a test, then you will either need to make sure you have the latest distribution of Rakudo Star, or install the module yourself using a package manager.
See the [Raku documentation on modules](https://docs.raku.org/language/modules#Looking_for_and_installing_modules.) for information on how to install modules.
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.rakumod"
"lib/Accumulate.rakumod"
],
"test": [
"accumulate.rakutest"
"t/accumulate.rakutest"
],
"example": [
".meta/solutions/Accumulate.rakumod"
".meta/solutions/lib/Accumulate.rakumod"
]
},
"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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env raku
use Test;
use lib $?FILE.IO.dirname;
use lib $?FILE.IO.parent(2).add('lib');
use Accumulate;

cmp-ok( # begin: 64d97c14-36dd-44a8-9621-2cecebd6ed23
Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/acronym/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
],
"files": {
"solution": [
"Acronym.rakumod"
"lib/Acronym.rakumod"
],
"test": [
"acronym.rakutest"
"t/acronym.rakutest"
],
"example": [
".meta/solutions/Acronym.rakumod"
".meta/solutions/lib/Acronym.rakumod"
]
},
"blurb": "Convert a long phrase to its acronym.",
Expand Down

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env raku
use Test;
use lib $?FILE.IO.dirname;
use lib $?FILE.IO.parent(2).add('lib');
use Acronym;

cmp-ok( # begin: 1e22cceb-c5e4-4562-9afe-aef07ad1eaf4
Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/affine-cipher/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
],
"files": {
"solution": [
"AffineCipher.rakumod"
"lib/AffineCipher.rakumod"
],
"test": [
"affine-cipher.rakutest"
"t/affine-cipher.rakutest"
],
"example": [
".meta/solutions/AffineCipher.rakumod"
".meta/solutions/lib/AffineCipher.rakumod"
]
},
"blurb": "Create an implementation of the Affine cipher, an ancient encryption algorithm from the Middle East.",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env raku
use Test;
use lib $?FILE.IO.dirname;
use lib $?FILE.IO.parent(2).add('lib');
use AffineCipher;

cmp-ok( # begin: 2ee1d9af-1c43-416c-b41b-cefd7d4d2b2a
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 @@ -7,13 +7,13 @@
],
"files": {
"solution": [
"AllYourBase.rakumod"
"lib/AllYourBase.rakumod"
],
"test": [
"all-your-base.rakutest"
"t/all-your-base.rakutest"
],
"example": [
".meta/solutions/AllYourBase.rakumod"
".meta/solutions/lib/AllYourBase.rakumod"
]
},
"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
@@ -1,6 +1,6 @@
#!/usr/bin/env raku
use Test;
use lib $?FILE.IO.dirname;
use lib $?FILE.IO.parent(2).add('lib');
use AllYourBase;

cmp-ok( # begin: 5ce422f9-7a4b-4f44-ad29-49c67cb32d2c
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 @@ -8,13 +8,13 @@
],
"files": {
"solution": [
"Allergies.rakumod"
"lib/Allergies.rakumod"
],
"test": [
"allergies.rakutest"
"t/allergies.rakutest"
],
"example": [
".meta/solutions/Allergies.rakumod"
".meta/solutions/lib/Allergies.rakumod"
]
},
"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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env raku
use Test;
use lib $?FILE.IO.dirname;
use lib $?FILE.IO.parent(2).add('lib');
use Allergies;

cmp-ok( # begin: 17fc7296-2440-4ac4-ad7b-d07c321bc5a0
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 @@ -11,13 +11,13 @@
],
"files": {
"solution": [
"Anagram.rakumod"
"lib/Anagram.rakumod"
],
"test": [
"anagram.rakutest"
"t/anagram.rakutest"
],
"example": [
".meta/solutions/Anagram.rakumod"
".meta/solutions/lib/Anagram.rakumod"
]
},
"blurb": "Given a word and a list of possible anagrams, select the correct sublist.",
Expand Down

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env raku
use Test;
use lib $?FILE.IO.dirname;
use lib $?FILE.IO.parent(2).add('lib');
use Anagram;

cmp-ok( # begin: dd40c4d2-3c8b-44e5-992a-f42b393ec373
Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/armstrong-numbers/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
],
"files": {
"solution": [
"ArmstrongNumbers.rakumod"
"lib/ArmstrongNumbers.rakumod"
],
"test": [
"armstrong-numbers.rakutest"
"t/armstrong-numbers.rakutest"
],
"example": [
".meta/solutions/ArmstrongNumbers.rakumod"
".meta/solutions/lib/ArmstrongNumbers.rakumod"
]
},
"blurb": "Determine if a number is an Armstrong number.",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env raku
use Test;
use lib $?FILE.IO.dirname;
use lib $?FILE.IO.parent(2).add('lib');
use ArmstrongNumbers;

cmp-ok( # begin: c1ed103c-258d-45b2-be73-d8c6d9580c7b
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 @@ -8,13 +8,13 @@
],
"files": {
"solution": [
"AtbashCipher.rakumod"
"lib/AtbashCipher.rakumod"
],
"test": [
"atbash-cipher.rakutest"
"t/atbash-cipher.rakutest"
],
"example": [
".meta/solutions/AtbashCipher.rakumod"
".meta/solutions/lib/AtbashCipher.rakumod"
]
},
"blurb": "Create an implementation of the atbash cipher, an ancient encryption system created in the Middle East.",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env raku
use Test;
use lib $?FILE.IO.dirname;
use lib $?FILE.IO.parent(2).add('lib');
use AtbashCipher;

cmp-ok( # begin: 2f47ebe1-eab9-4d6b-b3c6-627562a31c77
Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/beer-song/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"authors": ["m-dango"],
"files": {
"solution": [
"BeerSong.rakumod"
"lib/BeerSong.rakumod"
],
"test": [
"beer-song.rakutest"
"t/beer-song.rakutest"
],
"example": [
".meta/solutions/BeerSong.rakumod"
".meta/solutions/lib/BeerSong.rakumod"
]
},
"blurb": "Produce the lyrics to that beloved classic, that field-trip favorite: 99 Bottles of Beer on the Wall.",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env raku
use Test;
use lib $?FILE.IO.dirname;
use lib $?FILE.IO.parent(2).add('lib');
use BeerSong;

cmp-ok( # begin: 5a02fd08-d336-4607-8006-246fe6fa9fb0
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 @@ -4,13 +4,13 @@
],
"files": {
"solution": [
"BinarySearchTree.rakumod"
"lib/BinarySearchTree.rakumod"
],
"test": [
"binary-search-tree.rakutest"
"t/binary-search-tree.rakutest"
],
"example": [
".meta/solutions/BinarySearchTree.rakumod"
".meta/solutions/lib/BinarySearchTree.rakumod"
]
},
"blurb": "Insert and search for numbers in a binary tree.",
Expand Down

This file was deleted.

Loading

0 comments on commit be2dfe4

Please sign in to comment.