Course of Raku / Advanced / Testing and documentation 🆕 / Testing 🆕 / Exercises / Plan two checks
Solution: Plan two checks
Here is a possible solution to the task.
Code
use Test;
plan 2;
my @sorted = (3, 1, 2).sort;
is-deeply @sorted, [1, 2, 3], 'sorted';
is 10 % 3, 1, 'remainder';🦋 You can find the source code in the file test-a-list.raku.
Output
1..2
ok 1 - sorted
ok 2 - remainderComments
plan 2states the count before any test runs, so the1..2line appears first. If the file then ran a different number of checks, the suite would be reported as failing — a safeguarddone-testingcannot give you.is-deeplycompares the two lists for exact, type-aware equality. Sorting3, 1, 2gives1, 2, 3, which matches.iscompares two values for plain equality and reports both on failure. Here10 % 3is1, which matches the expected value, so the second test passes too.