Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
sub/hash syntax
  • Loading branch information
ivanoff committed Aug 11, 2013
1 parent 8abf073 commit 121d672
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions S13-syntax/sub-hash.t
@@ -0,0 +1,25 @@
use v6;

use Test;

plan 2;

# RT #76896:
# perl6 - sub/hash syntax

sub to_check {
my %fs = ();
%fs{ lc( 'A' ) } = &fa;
sub fa() { return 'fa called.'; }

%fs{ lc( 'B' ) } = &fb;
sub fb() { return 'fb called.'; }

my $fn = lc( @_[ 0 ] || 'A' );
return "%s\n", %fs{ $fn }();
}

is to_check, "\%s\n fa called.", 'fa called ok';
is to_check('B'), "\%s\n fb called.", 'fb called ok';

# vim: ft=perl6

0 comments on commit 121d672

Please sign in to comment.