Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
adding 2010 advent days 19 and 21
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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'; | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 Heading</h1> | ||
| <p>A paragraph.</p> | ||
| </body> | ||
| </html> | ||
| END | ||
| my $escaped = $html.trans( | ||
| [ '&', '<', '>' ] => | ||
| [ '&', '<', '>' ] | ||
| ); | ||
| is_deeply [$escaped.lines], [ | ||
| '<!DOCTYPE html>', | ||
| '<html>', | ||
| ' <body>', | ||
| ' <h1>My&nbsp;Heading</h1>', | ||
| ' <p>A paragraph.</p>', | ||
| ' </body>', | ||
| '</html>' | ||
| ], 'html escaping'; | ||