Skip to content

Instantly share code, notes, and snippets.

@JJ
Created December 5, 2019 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JJ/878fdc9e4f5a964948e3840586284273 to your computer and use it in GitHub Desktop.
Save JJ/878fdc9e4f5a964948e3840586284273 to your computer and use it in GitHub Desktop.
Simple Raku test using the Test library
#!/usr/bin/env perl6
use v6;
use Test;
constant $greeting = "Merry Xmas!";
constant $non-greeting = "Hey!";
is( greet( "Hey", $greeting, $non-greeting), $non-greeting, "Non-seasonal salutation OK");
is( greet( "Merry Xmas!", $greeting, $non-greeting), $greeting, "Seasonal salutation OK");
done-testing;
sub greet( $body, $greeting, $non-greeting ) {
($body ~~ /M|m "erry"/)??$greeting!!$non-greeting;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment