Created
December 5, 2019 15:32
-
-
Save JJ/878fdc9e4f5a964948e3840586284273 to your computer and use it in GitHub Desktop.
Simple Raku test using the Test library
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
#!/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