Initial Commit

This commit is contained in:
2016-08-13 18:20:14 -05:00
commit 50f4a86fd8
408 changed files with 15301 additions and 0 deletions

35
perl5/bob/README.md Normal file
View File

@@ -0,0 +1,35 @@
# Bob
Bob is a lackadaisical teenager. In conversation, his responses are very limited.
Bob answers 'Sure.' if you ask him a question.
He answers 'Whoa, chill out!' if you yell at him.
He says 'Fine. Be that way!' if you address him without actually saying
anything.
He answers 'Whatever.' to anything else.
## Instructions
Run the test file, and fix each of the errors in turn. When you get the
first test to pass, go to the first pending or skipped test, and make
that pass as well. When all of the tests are passing, feel free to
submit.
Remember that passing code is just the first step. The goal is to work
towards a solution that is as readable and expressive as you can make
it.
Please make your solution as general as possible. Good code doesn't just
pass the test suite, it works with any input that fits the
specification.
Have fun!
## Source
Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial. [view source](http://pine.fm/LearnToProgram/?Chapter=06)

24
perl5/bob/bob.pm Normal file
View File

@@ -0,0 +1,24 @@
#
# This is a SKELETON file and has been provided to enable you to get working on the
# first exercise more quickly.
#
use 5.006;
use strict;
use warnings;
package Bob;
our $VERSION = '1.000';
use Exporter 5.57 qw(import);
our @EXPORT_OK = qw(hey);
sub hey {
#
# YOUR CODE GOES HERE
#
}
1;

61
perl5/bob/bob.t Normal file
View File

@@ -0,0 +1,61 @@
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();