Created
April 11, 2012 19:28
-
-
Save Shinpeim/2361718 to your computer and use it in GitHub Desktop.
UuuuNyaaa!
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
package Acme::UuuuNyaaa; | |
use strict; | |
use warnings; | |
sub new{ | |
my $class = shift; | |
my $self = bless {}, $class; | |
return $self; | |
} | |
sub u{ | |
return "(」・ω・)」うー!"; | |
} | |
sub n{ | |
return "(/・ω・)/にゃー!"; | |
} | |
sub un{ | |
my $self = shift; | |
return $self->u.$self->n; | |
} | |
sub ln{ | |
return "Let's\(・ω・)/にゃー!"; | |
} | |
sub response{ | |
my ($self,$text) = @_; | |
if ($text =~ m{う[〜ー]}msix) { | |
return $self->n; | |
} | |
else { | |
return $self->ln; | |
} | |
} | |
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
use strict; | |
use Test::More; | |
BEGIN{ | |
use_ok('Acme::UuuuNyaaa'); | |
} | |
my $unya = Acme::UuuuNyaaa->new; | |
ok($unya->u eq "(」・ω・)」うー!", "うー!"); | |
ok($unya->n eq "(/・ω・)/にゃー!", "にゃー!"); | |
ok($unya->un eq "(」・ω・)」うー!(/・ω・)/にゃー!", "うー!にゃー!"); | |
ok($unya->ln eq "Let's\(・ω・)/にゃー!", "Lets!にゃー!"); | |
subtest "response to u" => sub { | |
for my $text ("うー", "う〜") { | |
ok($unya->response($text) eq $unya->n); | |
} | |
}; | |
subtest "fallback" => sub { | |
ok($unya->response("no match") eq $unya->ln); | |
}; | |
done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment