exercise: Bob
version: 3
plan: 26
methods: hey
tests: |-
# Go through the cases and check that Bob gives us the correct responses.
is Bob.?hey(.), |. for @($c-data);
version_comment: The version we will be matching against the exercise.
lib_comment: Look for the module inside the same directory as this test file.
plan_comment: This is how many tests we expect to run.
version_test_comment: "If the exercise is updated, we want to make sure other people testing\nyour code don't think you've made a mistake if things have changed!"
methods_comment: "Check that the class 'Bob' can use all of the methods\nneeded in the tests (only 'hey' for this one)."
unit: class
unit_comment: |-
#`[
Declare class 'Bob' with version and unit-scope the class
i.e. everything in this file is part of 'Bob'.
]
example: |-
method hey ( Str:D $_ --> Str:D ) {
my \shouting = /<:L>/ ^ /<:Ll>/;
given .trim {
when .ends-with: ‘?’ {
when shouting { ‘Calm down, I know what I'm doing!’ }
default { ‘Sure.’ }
}
when shouting { ‘Whoa, chill out!’ }
when .not { ‘Fine. Be that way!’ }
default { ‘Whatever.’ };
}
}
stub: |-
method hey ($msg) {
#`[
Remove the comments and write some code here to pass the test suite.
You can experiment with the code outside of this block,
but no changes are needed for the test suite to pass.
]
}