Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
adding 2010 advent days 19 and 21
  • Loading branch information
dwarring committed May 21, 2014
1 parent a835db1 commit 2cee534
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
23 changes: 23 additions & 0 deletions integration/advent2010-day19.t
@@ -0,0 +1,23 @@
# http://perl6advent.wordpress.com/2010/12/19/day-19-false-truth/
use v6;
use Test;
plan 6;

{
my $value = 42 but role { method Bool { False } };
is $value, 42, 'but role {...}';
is ?$value, False, 'but role {...}';
}

{
my $value = 42 but False;
is $value, 42, '42 but False';
is ?$value, False, '42 but False';
}

{
my $value = True but False;
#?rakudo todo "RT121940 - should be 'True'"
is $value, True, 'True but False';
is ?$value, False, 'True but False';
}
38 changes: 38 additions & 0 deletions integration/advent2010-day21.t
@@ -0,0 +1,38 @@
# http://perl6advent.wordpress.com/2010/12/21/day-21-transliteration-and-beyond/
use v6;
use Test;
plan 4;

is "GATTACA".trans( "TCAG" => "0123" ), "3200212", 'trans';
sub rot13($text) { $text.trans( "A..Za..z" => "N..ZA..Mn..za..m" ) }
is rot13('Why did the chicken cross the road?'), 'Jul qvq gur puvpxra pebff gur ebnq?', 'rot13';

my $kabbala = 'To get to the other side!';
$kabbala.=trans("A..Ia..i" => "1..91..9");
is $kabbala, 'To 75t to t85 ot85r s945!', 'kabbala';

my $html = q:to"END";
<!DOCTYPE html>
<html>
<body>
<h1>My&nbsp;Heading</h1>
<p>A paragraph.</p>
</body>
</html>
END
my $escaped = $html.trans(
[ '&', '<', '>' ] =>
[ '&amp;', '&lt;', '&gt;' ]
);
is_deeply [$escaped.lines], [
'&lt;!DOCTYPE html&gt;',
'&lt;html&gt;',
' &lt;body&gt;',
' &lt;h1&gt;My&amp;nbsp;Heading&lt;/h1&gt;',
' &lt;p&gt;A paragraph.&lt;/p&gt;',
' &lt;/body&gt;',
'&lt;/html&gt;'
], 'html escaping';

0 comments on commit 2cee534

Please sign in to comment.