root/t/perl5/roundtrip.t

Revision 20490, 0.9 kB (checked in by Auzon, 8 months ago)

s/use v6-alpha;$/use v6;/;
Also catching a few other mentions of v6-alpha.

  • Property svn:mime-type set to text/plain; charset=UTF-8
  • Property svn:eol-style set to native
Line 
1use v6;
2
3use Test;
4
5plan(5);
6
7unless eval 'eval("1", :lang<perl5>)' {
8    skip_rest;
9    exit;
10}
11
12eval(q/
13package Id;
14sub new {
15    my ($class, $ref) = @_;
16    bless \$ref, $class;
17}
18sub identity {
19    my $self = shift;
20    return $$self;
21}
22/, :lang<perl5>);
23
24my $japh    = { "Just another $_ hacker" };
25my $japh2   = -> $name { "Just another $name hacker" };
26my $id      = eval('sub { Id->new($_[0]) }', :lang<perl5>);
27
28is($id($japh).identity.('Pugs'), 'Just another Pugs hacker', "Closure roundtrips");
29is($id($japh2).identity.('Pugs'), 'Just another Pugs hacker', "Closure roundtrips");
30
31my $keys_p5 = eval('sub {keys %{$_[0]}}', :lang<perl5>);
32my $tohash_p5 = eval('sub { return {map {$_ => 1} @_ } }', :lang<perl5>);
33my %hash = (foo => 'bar', hate => 'software');
34{
35    my $foo = $tohash_p5.(keys %hash);
36    cmp_ok($foo, &infix:<cmp>, %hash);
37    is_deeply([$foo.keys].sort, [%hash.keys].sort);
38}
39
40{
41    is_deeply([%hash.keys].sort, [$keys_p5(VAR %hash)].sort);
42}
Note: See TracBrowser for help on using the browser.