Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
adding advent 2013 day 06
  • Loading branch information
dwarring committed Apr 13, 2014
1 parent 13206ce commit f57331b
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions integration/advent2012-day06.t
@@ -0,0 +1,44 @@
use v6;
use Test;

plan 2;

BEGIN { @*INC.push: 't/spec/packages' }

use Test::Util;

my $main = q:to"END-MAIN";
use v6;
use lib 'lib';
# the main functionality of the script
sub deduplicate(Str $s) {
my %seen;
$s.comb.grep({!%seen{ .lc }++}).join;
}
# normal call
multi MAIN($phrase) {
say deduplicate($phrase)
}
# if you call the script with --test, it runs its unit tests
multi MAIN(Bool :$test!) {
# imports &plan, &is etc. only into the lexical scope
use Test;
plan 2;
is deduplicate('just some words'),
'just omewrd', 'basic deduplication';
is deduplicate('Abcabd'),
'Abcd', 'case insensitivity';
}
END-MAIN

is_run $main, {
out => "Duplicate hrmov\n", err => ''}, :args['Duplicate character removal'], 'normal main call';

is_run $main, {out => q:to"END-TEST-OUT", er => ''}, :args['--test'], 'test main call';
1..2
ok 1 - basic deduplication
ok 2 - case insensitivity
END-TEST-OUT

0 comments on commit f57331b

Please sign in to comment.