-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Colin Leach
committed
Dec 16, 2024
1 parent
85c4e6f
commit 5d56398
Showing
5 changed files
with
249 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
# Help | ||
|
||
## Running the tests | ||
|
||
This track uses the [Unitt unit-testing package][unitt], installed automatically when running the tests. | ||
From within the exercise folder, run `exercism test` or `arturo tester.art` to run your solution against the test suite. | ||
|
||
If you haven't written any code, the test suite will fail with a message like: | ||
|
||
```plaintext | ||
===== tests\test-leap.art ===== | ||
Suite: Leap | ||
══╡ Program Error ╞═════════════════════════════════════════════════ <script> ══ | ||
please implement the isLeap? function | ||
===== Statistics ===== | ||
⏏️ TOTAL: 0 assertions | ||
✅ PASSED: 0 assertions | ||
⏩ SKIPPED: 0 assertions | ||
❌ FAILED: 0 assertions | ||
===== ========== ===== | ||
``` | ||
|
||
Replace the `panic "please implement the <some-function-name> function"` line in `src\<your-exercise>.art` with your solution. | ||
Then rerun the test suite, and you should see something like: | ||
|
||
```plaintext | ||
===== tests\test-leap.art ===== | ||
Suite: Leap | ||
✅ - assert that a year not divisible by 4 is a common year | ||
assertion: false = false | ||
⏩ - assert that a year divisible by 2 and not divisible by 4 is a common year | ||
skipped! | ||
⏩ - assert that a year divisible by 4 and not divisible by 100 is a leap year | ||
skipped! | ||
===== Statistics ===== | ||
⏏️ TOTAL: 1 assertions | ||
✅ PASSED: 1 assertions | ||
⏩ SKIPPED: 2 assertions | ||
❌ FAILED: 0 assertions | ||
===== ========== ===== | ||
``` | ||
|
||
The output lists the test file path, the name of the test suite, and the test case assertions, reporting whether a test had passed (✅), failed (❌) or was skipped (⏩). | ||
|
||
The following test file has three tests, one of which is skipped. | ||
Unskip a test by replacing `test.skip` with `test` beside the description for the test. | ||
|
||
```arturo | ||
import {unitt}! | ||
import {src/leap}! | ||
suite "Leap" [ | ||
test "a year not divisible by 4 is a common year" [ | ||
result: isLeap? 2015 | ||
assert -> false = result | ||
] | ||
test "a year divisible by 2 and not divisible by 4 is a common year" [ | ||
result: isLeap? 1970 | ||
assert -> false = result | ||
] | ||
test.skip "a year divisible by 4 and not divisible by 100 is a leap year" [ | ||
result: isLeap? 1996 | ||
assert -> true = result | ||
] | ||
] | ||
``` | ||
|
||
If we rerun the tests again, the second test is run and passes, but the third test is still skipped. | ||
|
||
|
||
```plaintext | ||
===== tests\test-leap.art ===== | ||
Suite: Leap | ||
✅ - assert that a year not divisible by 4 is a common year | ||
assertion: false = false | ||
✅ - assert that a year divisible by 2 and not divisible by 4 is a common year | ||
assertion: false = false | ||
⏩ - assert that a year divisible by 4 and not divisible by 100 is a leap year | ||
skipped! | ||
===== Statistics ===== | ||
⏏️ TOTAL: 2 assertions | ||
✅ PASSED: 2 assertions | ||
⏩ SKIPPED: 1 assertions | ||
❌ FAILED: 0 assertions | ||
===== ========== ===== | ||
``` | ||
|
||
A failed test would look like this | ||
|
||
```plaintext | ||
===== tests/test-leap.art ===== | ||
Suite: Leap | ||
✅ - assert that a year not divisible by 4 is a common year | ||
assertion: false = false | ||
✅ - assert that a year divisible by 2 and not divisible by 4 is a common year | ||
assertion: false = false | ||
❌ - assert that a year divisible by 4 and not divisible by 100 is a leap year | ||
assertion: true = false | ||
===== Statistics ===== | ||
⏏️ TOTAL: 3 assertions | ||
✅ PASSED: 2 assertions | ||
⏩ SKIPPED: 0 assertions | ||
❌ FAILED: 1 assertions | ||
===== ========== ===== | ||
``` | ||
|
||
Once all tests pass, you can submit your solution using `exercism submit`. | ||
|
||
[packager]: https://pkgr.art/ | ||
|
||
## Submitting your solution | ||
|
||
You can submit your solution using the `exercism submit src/two-fer.art` command. | ||
This command will upload your solution to the Exercism website and print the solution page's URL. | ||
|
||
It's possible to submit an incomplete solution which allows you to: | ||
|
||
- See how others have completed the exercise | ||
- Request help from a mentor | ||
|
||
## Need to get help? | ||
|
||
If you'd like help solving the exercise, check the following pages: | ||
|
||
- The [Arturo track's documentation](https://exercism.org/docs/tracks/arturo) | ||
- The [Arturo track's programming category on the forum](https://forum.exercism.org/c/programming/arturo) | ||
- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5) | ||
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) | ||
|
||
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. | ||
|
||
Here are some resources for getting help if you run into trouble | ||
|
||
* [Official Documentation][official-docs] covers syntax, language features, and the standard library modules. | ||
* [Arturo Discord][discord] is Arturo's official Discord server. | ||
* [Rosetta Code][rosetta-code] has over 770+ Arturo code examples for many different tasks. | ||
|
||
[official-docs]: https://arturo-lang.io/master/documentation/ | ||
[discord]: https://discord.gg/YdVK2CB | ||
[rosetta-code]: https://rosettacode.org/wiki/Category:Arturo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Two Fer | ||
|
||
Welcome to Two Fer on Exercism's Arturo Track. | ||
If you need help running the tests or submitting your code, check out `HELP.md`. | ||
|
||
## Introduction | ||
|
||
In some English accents, when you say "two for" quickly, it sounds like "two fer". | ||
Two-for-one is a way of saying that if you buy one, you also get one for free. | ||
So the phrase "two-fer" often implies a two-for-one offer. | ||
|
||
Imagine a bakery that has a holiday offer where you can buy two cookies for the price of one ("two-fer one!"). | ||
You take the offer and (very generously) decide to give the extra cookie to someone else in the queue. | ||
|
||
## Instructions | ||
|
||
Your task is to determine what you will say as you give away the extra cookie. | ||
|
||
If you know the person's name (e.g. if they're named Do-yun), then you will say: | ||
|
||
```text | ||
One for Do-yun, one for me. | ||
``` | ||
|
||
If you don't know the person's name, you will say _you_ instead. | ||
|
||
```text | ||
One for you, one for me. | ||
``` | ||
|
||
Here are some examples: | ||
|
||
| Name | Dialogue | | ||
| :----- | :-------------------------- | | ||
| Alice | One for Alice, one for me. | | ||
| Bohdan | One for Bohdan, one for me. | | ||
| | One for you, one for me. | | ||
| Zaphod | One for Zaphod, one for me. | | ||
|
||
## Source | ||
|
||
### Created by | ||
|
||
- @BNAndras | ||
|
||
### Based on | ||
|
||
https://github.com/exercism/problem-specifications/issues/757 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
twoFer: function [name][ | ||
switch name = "" -> "One for you, one for me." | ||
-> ~"One for |name|, one for me." | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import {unitt}! | ||
|
||
runTests.failFast findTests "tests" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {unitt}! | ||
import {src/two-fer}! | ||
|
||
suite "Two Fer" [ | ||
test "no name given" [ | ||
result: twoFer "" | ||
assert -> "One for you, one for me." = result | ||
] | ||
|
||
test "a name given" [ | ||
result: twoFer "Alice" | ||
assert -> "One for Alice, one for me." = result | ||
] | ||
|
||
test "another name given" [ | ||
result: twoFer "Bob" | ||
assert -> "One for Bob, one for me." = result | ||
] | ||
] |