Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use 'Perl5' as consistent name for EVAL and use :from
  • Loading branch information
niner committed Jul 18, 2015
1 parent a8a86ef commit a8ce6fb
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 52 deletions.
6 changes: 3 additions & 3 deletions S01-perl-5-integration/array.t
Expand Up @@ -4,7 +4,7 @@ use Test;

plan 17;

unless (try { EVAL("1", :lang<perl5>) }) {
unless (try { EVAL("1", :lang<Perl5>) }) {
skip-rest;
exit;
}
Expand Down Expand Up @@ -50,9 +50,9 @@ sub push {
}
1;
/, :lang<perl5>);
/, :lang<Perl5>);

my $p5ar = EVAL('sub { My::Array->new($_[0]) }', :lang<perl5>);
my $p5ar = EVAL('sub { My::Array->new($_[0]) }', :lang<Perl5>);
my @array = (5,6,7,8);
my $p5array = $p5ar($@array);

Expand Down
12 changes: 6 additions & 6 deletions S01-perl-5-integration/basic.t
Expand Up @@ -2,27 +2,27 @@ use v6;
use Test;
plan 15;

unless (try { EVAL("1", :lang<perl5>) }) {
unless (try { EVAL("1", :lang<Perl5>) }) {
skip-rest;
exit;
}

{
my $r = EVAL("0", :lang<perl5>);
my $r = EVAL("0", :lang<Perl5>);
is($r, 0, "number");
}

{
my $r = EVAL("2", :lang<perl5>);
my $r = EVAL("2", :lang<Perl5>);
is($r, 2, "number");
}

{
my $r = EVAL('"perl6 now"', :lang<perl5>);
my $r = EVAL('"perl6 now"', :lang<Perl5>);
is($r, 'perl6 now', "string");
}

my $p5_dumper = EVAL('sub {return(wantarray ? @_ : $_[0]); }', :lang<perl5>);
my $p5_dumper = EVAL('sub {return(wantarray ? @_ : $_[0]); }', :lang<Perl5>);

my %h = ( a => 1 );

Expand Down Expand Up @@ -72,7 +72,7 @@ my $s = 'str';
my $test = q{ (&p6func) Passing a Perl 6 coderef to Perl 5 };

sub plus_one (Int $int) { $int+1 }
my $sub = EVAL('sub { my $p6_coderef = shift; $p6_coderef->(3) }', :lang<perl5>);
my $sub = EVAL('sub { my $p6_coderef = shift; $p6_coderef->(3) }', :lang<Perl5>);
my $result = $sub(&plus_one);
is($result,4,$test);
}
Expand Down
2 changes: 1 addition & 1 deletion S01-perl-5-integration/class.t
Expand Up @@ -4,7 +4,7 @@ use Test;

plan(3);

unless (try { EVAL("1", :lang<perl5>) }) {
unless (try { EVAL("1", :lang<Perl5>) }) {
skip-rest;
exit;
}
Expand Down
26 changes: 13 additions & 13 deletions S01-perl-5-integration/context.t
Expand Up @@ -8,14 +8,14 @@ my &p5_void := EVAL(
} else {
$::got_void = 1;
}
}',:lang<perl5>);
}',:lang<Perl5>);

p5_void(:context<void>);
is(EVAL(:lang<perl5>,'$::got_void'),1,":contex<void> sets void context");
is(EVAL(:lang<Perl5>,'$::got_void'),1,":contex<void> sets void context");
p5_void(:context<scalar>);
is(EVAL(:lang<perl5>,'$::got_void'),0,":contex<scalar> dosn't set void context");
is(EVAL(:lang<Perl5>,'$::got_void'),0,":contex<scalar> dosn't set void context");
p5_void(:context<list>);
is(EVAL(:lang<perl5>,'$::got_void'),0,":contex<list> dosn't sets void context");
is(EVAL(:lang<Perl5>,'$::got_void'),0,":contex<list> dosn't sets void context");

my &p5_scalar := EVAL(
'sub {
Expand All @@ -24,13 +24,13 @@ my &p5_scalar := EVAL(
} else {
$::got_scalar = 0;
}
}',:lang<perl5>);
}',:lang<Perl5>);
p5_scalar(:context<scalar>);
is(EVAL(:lang<perl5>,'$::got_scalar'),1,":contex<scalar> sets scalar context");
is(EVAL(:lang<Perl5>,'$::got_scalar'),1,":contex<scalar> sets scalar context");
p5_scalar(:context<void>);
is(EVAL(:lang<perl5>,'$::got_scalar'),0,":contex<void> dosn't set scalar context");
is(EVAL(:lang<Perl5>,'$::got_scalar'),0,":contex<void> dosn't set scalar context");
p5_scalar(:context<list>);
is(EVAL(:lang<perl5>,'$::got_scalar'),0,":contex<list> dosn't sets scalar context");
is(EVAL(:lang<Perl5>,'$::got_scalar'),0,":contex<list> dosn't sets scalar context");

my &p5_list := EVAL(
'sub {
Expand All @@ -39,15 +39,15 @@ my &p5_list := EVAL(
} else {
$::got_list = 0;
}
}',:lang<perl5>);
}',:lang<Perl5>);
p5_list(:context<list>);
is(EVAL(:lang<perl5>,'$::got_list'),1,":contex<list> sets list context");
is(EVAL(:lang<Perl5>,'$::got_list'),1,":contex<list> sets list context");
p5_list(:context<scalar>);
is(EVAL(:lang<perl5>,'$::got_list'),0,":contex<scalar> dosn't set list context");
is(EVAL(:lang<Perl5>,'$::got_list'),0,":contex<scalar> dosn't set list context");
p5_list(:context<void>);
is(EVAL(:lang<perl5>,'$::got_list'),0,":contex<void> dosn't sets list context");
is(EVAL(:lang<Perl5>,'$::got_list'),0,":contex<void> dosn't sets list context");

my &p5_list_of_values := EVAL('sub {return (1,2,3,4)}',:lang<perl5>);
my &p5_list_of_values := EVAL('sub {return (1,2,3,4)}',:lang<Perl5>);
ok(p5_list_of_values(:context<void>) === Nil,"a p5 sub called in void context returns a Nil");


Expand Down
2 changes: 1 addition & 1 deletion S01-perl-5-integration/eval_lex.t
Expand Up @@ -4,6 +4,6 @@ plan 1;

my $self = "some text";

is ~EVAL(q/"self is $self"/,:lang<perl5>),"self is some text","lexical inside an EVAL";
is ~EVAL(q/"self is $self"/,:lang<Perl5>),"self is some text","lexical inside an EVAL";

# vim: ft=perl6
6 changes: 3 additions & 3 deletions S01-perl-5-integration/exception_handling.t
Expand Up @@ -5,7 +5,7 @@ use Test;

BEGIN {
plan 3;
unless (try { EVAL("1", :lang<perl5>) }) {
unless (try { EVAL("1", :lang<Perl5>) }) {
skip-rest('no perl 5 support'); exit;
}
}
Expand All @@ -29,9 +29,9 @@ sub error {
}
sub test { "1" }
], :lang<perl5>);
], :lang<Perl5>);

my $foo = EVAL("Foo->new",:lang<perl5>);
my $foo = EVAL("Foo->new",:lang<Perl5>);
try { $foo.error };
lives-ok( {
my $err = $!;
Expand Down
6 changes: 3 additions & 3 deletions S01-perl-5-integration/hash.t
Expand Up @@ -4,7 +4,7 @@ use Test;

plan(6);

unless (try { EVAL("1", :lang<perl5>) }) {
unless (try { EVAL("1", :lang<Perl5>) }) {
skip-rest;
exit;
}
Expand Down Expand Up @@ -49,9 +49,9 @@ sub push {
}
1;
/, :lang<perl5>);
/, :lang<Perl5>);

my $p5ha = EVAL('sub { My::Hash->new($_[0]) }', :lang<perl5>);
my $p5ha = EVAL('sub { My::Hash->new($_[0]) }', :lang<Perl5>);
my %hash = (5 => 'a', 6 => 'b', 7 => 'c', 8 => 'd');
my $p5hash = $p5ha($%hash);

Expand Down
2 changes: 1 addition & 1 deletion S01-perl-5-integration/import.t
Expand Up @@ -9,7 +9,7 @@ P5 module import test
=end pod

unless (try { EVAL("1", :lang<perl5>) }) {
unless (try { EVAL("1", :lang<Perl5>) }) {
skip-rest;
exit;
}
Expand Down
10 changes: 5 additions & 5 deletions S01-perl-5-integration/method.t
Expand Up @@ -4,7 +4,7 @@ use Test;

plan(13);

unless (try { EVAL("1", :lang<perl5>) }) {
unless (try { EVAL("1", :lang<Perl5>) }) {
skip-rest;
exit;
}
Expand Down Expand Up @@ -58,17 +58,17 @@ sub invoke {
$obj->me ('invoking');
}
/, :lang<perl5>);
/, :lang<Perl5>);

{
my $r = EVAL("FooBar->VERSION", :lang<perl5>);
my $r = EVAL("FooBar->VERSION", :lang<Perl5>);
is($r, '6.0', "class method");
}

my $obj;

{
$obj = EVAL("FooBar->new", :lang<perl5>);
$obj = EVAL("FooBar->new", :lang<Perl5>);
#?rakudo todo "P5 classes not yet shadowed in P6"
{
isa-ok($obj, 'FooBar', "blessed");
Expand Down Expand Up @@ -120,7 +120,7 @@ my $obj;
method me ($class: $arg) { 'Foo6'~$arg }; #OK not used
};
my $obj6 = Foo6.new;
$obj = EVAL("FooBar->new", :lang<perl5>);
$obj = EVAL("FooBar->new", :lang<Perl5>);
is($obj.invoke($obj6), 'Foo6invoking', 'invoke p6 method from p5');
}

Expand Down
2 changes: 1 addition & 1 deletion S01-perl-5-integration/return.t
Expand Up @@ -4,7 +4,7 @@ use Test;

plan(2);

unless (try { EVAL("1", :lang<perl5>) }) {
unless (try { EVAL("1", :lang<Perl5>) }) {
skip-rest;
exit;
}
Expand Down
10 changes: 5 additions & 5 deletions S01-perl-5-integration/roundtrip.t
Expand Up @@ -4,7 +4,7 @@ use Test;

plan(5);

unless (try { EVAL("1", :lang<perl5>) }) {
unless (try { EVAL("1", :lang<Perl5>) }) {
skip-rest;
exit;
}
Expand All @@ -19,17 +19,17 @@ sub identity {
my $self = shift;
return $$self;
}
/, :lang<perl5>);
/, :lang<Perl5>);

my $japh = { "Just another $_ hacker" };
my $japh2 = -> $name { "Just another $name hacker" };
my $id = EVAL('sub { Id->new($_[0]) }', :lang<perl5>);
my $id = EVAL('sub { Id->new($_[0]) }', :lang<Perl5>);

is($id($japh).identity()('Pugs'), 'Just another Pugs hacker', "Closure roundtrips");
is($id($japh2).identity()('Pugs'), 'Just another Pugs hacker', "Closure roundtrips");

my $keys_p5 = EVAL('sub {keys %{$_[0]}}', :lang<perl5>);
my $tohash_p5 = EVAL('sub { return {map {$_ => 1} @_ } }', :lang<perl5>);
my $keys_p5 = EVAL('sub {keys %{$_[0]}}', :lang<Perl5>);
my $tohash_p5 = EVAL('sub { return {map {$_ => 1} @_ } }', :lang<Perl5>);
my %hash = (foo => 'bar', hate => 'software');
{
my $foo = $tohash_p5.(keys %hash);
Expand Down
14 changes: 7 additions & 7 deletions S01-perl-5-integration/strings.t
Expand Up @@ -2,23 +2,23 @@ use Test;

plan 6;

unless (try { EVAL("1", :lang<perl5>) }) {
unless (try { EVAL("1", :lang<Perl5>) }) {
skip-rest;
exit;
}

is(EVAL("'Yet Another Perl Hacker'",:lang<perl5>),"Yet Another Perl Hacker");
is(EVAL("'Yet Another Perl Hacker'",:lang<Perl5>),"Yet Another Perl Hacker");
#?rakudo todo "NativeCall strings not yet Null safe RT #124649"
{
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('"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");
is(EVAL('use utf8;"膮臋贸艣膰偶"',:lang<Perl5>),"膮臋贸艣膰偶","utf8 in literals");


my &test1 := EVAL('sub {$_[0] eq "Yet Another Perl Hacker"}',:lang<perl5>);
my &test1 := EVAL('sub {$_[0] eq "Yet Another Perl Hacker"}',:lang<Perl5>);

my &test2 := EVAL('sub {$_[0] eq "Yet Ano\0ther P\0erl Hacker"}',:lang<perl5>);
my &test3 := EVAL('sub {$_[0] eq "\x{105}\x{119}\x{f3}\x{15b}\x{107}\x{17c}"}',:lang<perl5>);
my &test2 := EVAL('sub {$_[0] eq "Yet Ano\0ther P\0erl Hacker"}',:lang<Perl5>);
my &test3 := EVAL('sub {$_[0] eq "\x{105}\x{119}\x{f3}\x{15b}\x{107}\x{17c}"}',:lang<Perl5>);

ok(test1("Yet Another Perl Hacker"),"Passing simple strings to p5 land");
ok(test2("Yet Ano\0ther P\0erl Hacker"),"Passing strings with null bytes to p5 land");
Expand Down
6 changes: 3 additions & 3 deletions S01-perl-5-integration/subs.t
Expand Up @@ -2,13 +2,13 @@ use v6;
use Test;
plan 2;

unless (try { EVAL("1", :lang<perl5>) }) {
unless (try { EVAL("1", :lang<Perl5>) }) {
skip-rest;
exit;
}

my &foo := EVAL('sub {432}',:lang<perl5>);
my &foo := EVAL('sub {432}',:lang<Perl5>);
is foo(),432,"calling subs works";

my $foo = EVAL('sub {432}',:lang<perl5>);
my $foo = EVAL('sub {432}',:lang<Perl5>);
is $foo(),432,"calling subs stored in variables works";

0 comments on commit a8ce6fb

Please sign in to comment.