Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fudge S01-perl-5-integration tests for rakudo
  • Loading branch information
niner committed Apr 17, 2015
1 parent 3c233f3 commit e5fe4c4
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 15 deletions.
20 changes: 14 additions & 6 deletions S01-perl-5-integration/array.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 18;
plan 17;

unless (try { EVAL("1", :lang<perl5>) }) {
skip_rest;
Expand Down Expand Up @@ -76,17 +76,25 @@ is($retarray[10]:exists, @array[10]:exists, 'retro nonexists' );
ok(($p5array.push(9)), 'can push');

is(0+$p5array.fetch(4), 9, 'push result via obj');
is(@array[4], 9, 'push result via array');
#?rakudo todo "doesn't work yet due to copying of arrays"
{
is(@array[4], 9, 'push result via array');
}

flunk("push(9) non-terminates");
#$retarray.push(9); # this will loop

is(0+$p5array.fetch(5), 9, 'retro push result');
is(@array[5], 9, 'retro push result');
#?rakudo todo "doesn't work yet due to copying of arrays"
{
is(0+$p5array.fetch(5), 9, 'retro push result');
is(@array[5], 9, 'retro push result');
}

ok($p5array.store(0,3), 'can store');

is(@array[0], 3, 'store result');
#?rakudo todo "doesn't work yet due to copying of arrays"
{
is(@array[0], 3, 'store result');
}
is(0+$p5array.fetch(0), 3, 'store result');

# TODO: pop, shift, unshift, splice, delete
Expand Down
1 change: 1 addition & 0 deletions S01-perl-5-integration/basic.t
Expand Up @@ -77,6 +77,7 @@ my $s = 'str';
is($result,4,$test);
}

#?rakudo skip "would need v5"
{
sub add_in_perl5 ($x, $y) {
use v5;
Expand Down
5 changes: 4 additions & 1 deletion S01-perl-5-integration/class.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan(2);
plan(3);

unless (try { EVAL("1", :lang<perl5>) }) {
skip_rest;
Expand All @@ -14,7 +14,10 @@ unless (try { EVAL("1", :lang<perl5>) }) {
EVAL q|
use Digest::MD5:from<Perl5>;
my $d = Digest::MD5.new;
#?rakudo skip ""
{
is $d.isa(Digest::MD5), 1, "Correct isa";
}
$d.add('foo'.encode('UTF-8'));
is $d.hexdigest, 'acbd18db4cc2f85cedef654fccc4a4d8';
|
Expand Down
7 changes: 5 additions & 2 deletions S01-perl-5-integration/hash.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan(5);
plan(6);

unless EVAL 'EVAL("1", :lang<perl5>)' {
skip_rest;
Expand Down Expand Up @@ -66,7 +66,10 @@ try {
is("{ @keys }", "{ @p5keys }");

ok($p5hash.store(9, 'e'), 'can store');
is(%hash{9}, 'e', 'store result');
#?rakudo todo "doesn't work yet due to copying of hashes"
{
is(%hash{9}, 'e', 'store result');
}

is($p5hash.fetch(5), 'a', 'fetch result');
is($p5hash.my_exists(5), +(%hash<5>:exists), 'exists');
Expand Down
8 changes: 6 additions & 2 deletions S01-perl-5-integration/import.t
@@ -1,7 +1,7 @@
use v6;

use Test;
plan 1;
plan 3;

=begin pod
Expand All @@ -16,7 +16,11 @@ unless (try { EVAL("1", :lang<perl5>) }) {

eval_lives_ok(q[
use Text::Wrap:from<Perl5> 'wrap';
is(Text::Wrap::wrap('foo', 'bar', 'baz'), 'foobaz', "import p5 module");
#?rakudo skip "importing of functions NYI"
{
is(wrap('foo', 'bar', 'baz'), 'foobaz', "import p5 module");
],"parse :from<perl5> syntax");
}
],"parse :from<Perl5> syntax");

# vim: ft=perl6
15 changes: 12 additions & 3 deletions S01-perl-5-integration/method.t
Expand Up @@ -69,8 +69,14 @@ my $obj;

{
$obj = EVAL("FooBar->new", :lang<perl5>);
isa_ok($obj, 'FooBar', "blessed");
like($obj, rx:Perl5/FooBar/, "blessed");
#?rakudo todo "P5 classes not yet shadowed in P6"
{
isa_ok($obj, 'FooBar', "blessed");
}
{
#?rakudo skip "Probably bogus test. Tests if the P5 object stringifies to something containing the class name, like FooBar=HASH(0x12345678)"
like($obj, rx:Perl5/FooBar/, "blessed");
}
}

{
Expand Down Expand Up @@ -121,7 +127,10 @@ my $obj;
{
my @rw = (1, 2, 3);
$obj.modify_array(VAR @rw);
is(@rw[0], 99, 'modify a scalar ref');
#?rakudo todo "doesn't work yet due to copying of arrays"
{
is(@rw[0], 99, 'modify a scalar ref');
}
}

# vim: ft=perl6
1 change: 1 addition & 0 deletions S01-perl-5-integration/return.t
Expand Up @@ -19,6 +19,7 @@ sub get_dmd5 {
}
{
#?rakudo skip "Importing functions NYI"
is( md5_hex('test'), '098f6bcd4621d373cade4e832627b4f6', 'perl5 function exported' );
}
Expand Down
5 changes: 4 additions & 1 deletion S01-perl-5-integration/strings.t
Expand Up @@ -3,7 +3,10 @@ use Test;
plan 6;

is(EVAL("'Yet Another Perl Hacker'",:lang<perl5>),"Yet Another Perl Hacker");
is(EVAL('"Yet Ano\0ther P\0erl Hacker"',:lang<perl5>),"Yet Ano\0ther P\0erl Hacker","Null Bytes in the middle of a converted string");
#?rakudo todo "NativeCall strings not yet Null safe"
{
is(EVAL('"Yet Ano\0ther P\0erl Hacker"',:lang<perl5>),"Yet Ano\0ther P\0erl Hacker","Null Bytes in the middle of a converted string");
}
is(EVAL('use utf8;"膮臋贸艣膰偶"',:lang<perl5>),"膮臋贸艣膰偶","utf8 in literals");


Expand Down

0 comments on commit e5fe4c4

Please sign in to comment.