|
Revision 20490, 1.2 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 | |
|---|
| 1 | use v6; |
|---|
| 2 | |
|---|
| 3 | use Test; |
|---|
| 4 | |
|---|
| 5 | plan(5); |
|---|
| 6 | |
|---|
| 7 | unless eval 'eval("1", :lang<perl5>)' { |
|---|
| 8 | skip_rest; |
|---|
| 9 | exit; |
|---|
| 10 | } |
|---|
| 11 | |
|---|
| 12 | die unless |
|---|
| 13 | eval(q/ |
|---|
| 14 | package My::Hash; |
|---|
| 15 | use strict; |
|---|
| 16 | |
|---|
| 17 | sub new { |
|---|
| 18 | my ($class, $ref) = @_; |
|---|
| 19 | bless \$ref, $class; |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | sub hash { |
|---|
| 23 | my $self = shift; |
|---|
| 24 | return $$self; |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | sub my_keys { |
|---|
| 28 | my $self = shift; |
|---|
| 29 | return keys %{$$self}; |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | sub my_exists { |
|---|
| 33 | my ($self, $idx) = @_; |
|---|
| 34 | return exists $$self->{$idx}; |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | sub fetch { |
|---|
| 38 | my ($self, $idx) = @_; |
|---|
| 39 | return $$self->{$idx}; |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | sub store { |
|---|
| 43 | my ($self, $idx, $val) = @_; |
|---|
| 44 | $$self->{$idx} = $val; |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | sub push { |
|---|
| 48 | my ($self, $val) = @_; |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | 1; |
|---|
| 52 | /, :lang<perl5>); |
|---|
| 53 | |
|---|
| 54 | my $p5ha = eval('sub { My::Hash->new($_[0]) }', :lang<perl5>); |
|---|
| 55 | my %hash = (5 => 'a', 6 => 'b', 7 => 'c', 8 => 'd'); |
|---|
| 56 | my $p5hash = $p5ha(\%hash); |
|---|
| 57 | |
|---|
| 58 | my $rethash = $p5hash.hash; |
|---|
| 59 | my @keys = %hash.keys.sort; |
|---|
| 60 | my @p5keys; |
|---|
| 61 | try { |
|---|
| 62 | @p5keys = $p5hash.my_keys; # this doesn't even pass lives_ok ?? |
|---|
| 63 | @p5keys .= sort; |
|---|
| 64 | }; |
|---|
| 65 | |
|---|
| 66 | is("{ @keys }", "{ @p5keys }"); |
|---|
| 67 | |
|---|
| 68 | ok($p5hash.store(9, 'e'), 'can store'); |
|---|
| 69 | is(%hash{9}, 'e', 'store result'); |
|---|
| 70 | |
|---|
| 71 | is($p5hash.fetch(5), 'a', 'fetch result'); |
|---|
| 72 | is($p5hash.my_exists(5), %hash.exists(5), 'exists'); |
|---|
| 73 | is($p5hash.my_exists(12), %hash.exists(12), 'nonexists fail', :todo<bug>); |
|---|