Created
December 6, 2016 09:42
-
-
Save realistschuckle/2fdd651f01daca46c399c6c8b6202f10 to your computer and use it in GitHub Desktop.
Lab 1
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
# | |
# This is a SKELETON file and has been provided to enable you to get working on the | |
# first exercise more quickly. | |
# | |
# Go down to lines 21-28, read the comment, delete it, and | |
# write some code to make the tests pass. | |
# | |
use strict; | |
use warnings; | |
package Bob; | |
our $VERSION = '1.000'; | |
use Exporter 5.57 qw(import); | |
our @EXPORT_OK = qw(hey); | |
sub hey { | |
my $input = shift @_; | |
# | |
# YOUR CODE GOES HERE | |
# | |
# THE VARIABELE $input CONTAINS | |
# THE STRING PASSED INTO THE | |
# SUBROUTINE, SUCH AS "WATCH OUT!" | |
# OR "Tom-ay-to, tom-aaaah-to." | |
# | |
} | |
1; |
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 perl | |
use strict; | |
use warnings; | |
use open ':std', ':encoding(utf8)'; | |
use utf8; | |
my $module = $ENV{EXERCISM} ? 'Example' : 'Bob'; | |
use Test::More; | |
my @cases = map { | |
{ | |
input => $_->[0], | |
expect => $_->[1], | |
desc => $_->[2], | |
} | |
} ( | |
# input expected output title | |
['Tom-ay-to, tom-aaaah-to.', 'Whatever.', 'stating something'], | |
# ['WATCH OUT!', 'Whoa, chill out!', 'shouting'], | |
# ['Does this cryogenic chamber make me look fat?', 'Sure.', 'question'], | |
# ['You are, what, like 15?', 'Sure.', 'numeric question'], | |
# ["Let's go make out behind the gym!", 'Whatever.', 'talking forcefully'], | |
# ["It's OK if you don't want to go to the DMV.", 'Whatever.', 'using acronyms in regular speech'], | |
# ['WHAT THE HELL WERE YOU THINKING?', 'Whoa, chill out!', 'forceful questions'], | |
# ['1, 2, 3 GO!', 'Whoa, chill out!', 'shouting numbers'], | |
# ['1, 2, 3', 'Whatever.', 'only numbers'], | |
# ['4?', 'Sure.', 'question with only numbers'], | |
# ['ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!', 'Whoa, chill out!', 'shouting with special characters'], | |
# ["ÜMLÄÜTS!", 'Whoa, chill out!', 'shouting with umlauts'], | |
# ["\xdcML\xc4\xdcTS!", 'Whoa, chill out!', 'shouting with umlauts'], | |
# ['_A', 'Whoa, chill out!', 'underscore shout - before'], | |
# ['A_', 'Whoa, chill out!', 'underscore shout - after'], | |
# ['$A', 'Whoa, chill out!', 'Dollar sign shout - before'], | |
# ['A$', 'Whoa, chill out!', 'Dollar sign shout - after'], | |
# ["ÜMLäÜTS!", 'Whatever.', 'speaking calmly with umlauts'], | |
# ['I HATE YOU', 'Whoa, chill out!', 'shouting with no exclamation mark'], | |
# ['Ending with ? means a question.', 'Whatever.', 'statement containing question mark'], | |
# ["Wait! Hang on. Are you going to be OK?", 'Sure.', 'prattling on'], | |
# ['', 'Fine. Be that way!', 'silence'], | |
# [' ', 'Fine. Be that way!', 'prolonged silence'], | |
# [" \nI just remembered...", 'Whatever.', 'Silence, then more'], | |
); | |
ok -e "$module.pm", "missing $module.pm" | |
or BAIL_OUT("You need to create a module called $module.pm with a function called hey() that gets one parameter: The text Bob hears."); | |
use_ok($module) | |
or BAIL_OUT("Does $module.pm compile? Does it end with 1; ?"); | |
can_ok($module, 'hey') | |
or BAIL_OUT("Missing package $module; or missing sub hey()"); | |
my $sub = $module->can('hey'); | |
foreach my $c (@cases) { | |
#diag uc $c->{input}; | |
my $title = $c->{desc} ? "$c->{desc}: $c->{input}" : $c->{input}; | |
is $sub->( $c->{input} ), $c->{expect}, $title; | |
} | |
done_testing(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment