Permalink
Browse files

Rename Perl 5 interpreter variable in tests and examples to $p5

Suggested by abraxxa++
  • Loading branch information...
niner committed Sep 14, 2014
1 parent 5c89aae commit cc683dae98df19db8cfbb551f7a87ef79bdc2a8b
Showing with 86 additions and 86 deletions.
  1. +23 −23 README.md
  2. +4 −4 inline_perl5.pl
  3. +15 −15 t/call.t
  4. +5 −5 t/call_back.t
  5. +4 −4 t/eval.t
  6. +4 −4 t/eval_return_values.t
  7. +8 −8 t/inherit.t
  8. +10 −10 t/p5_to_p6.t
  9. +4 −4 t/p6_object_destructor.t
  10. +4 −4 t/p6_to_p5.t
  11. +5 −5 t/use.t
View
@@ -6,9 +6,9 @@ Inline::Perl5
```
use Inline::Perl5;
my $i = Inline::Perl5.new();
$i.use('DBI');
my $dbh = $i.invoke('DBI', 'connect', 'dbi:Pg:database=test');
my $p5 = Inline::Perl5.new();
$p5.use('DBI');
my $dbh = $p5.invoke('DBI', 'connect', 'dbi:Pg:database=test');
my $products = $dbh.selectall_arrayref(
'select * from products', {Slice => {}}
);
@@ -31,8 +31,8 @@ Inline::Perl5's use() method maps to Perl 5's use statement:
```
use Inline::Perl5;
my $i = Inline::Perl5.new;
$i.use('Test::More');
my $p5 = Inline::Perl5.new;
$p5.use('Test::More');
```
## Call a Perl 5 function
@@ -43,10 +43,10 @@ is not in the "main" namespace.
```
use Inline::Perl5;
my $i = Inline::Perl5.new;
$i.call('print', 'Hello World');
$i.use('Test::More');
$i.call('Test::More::plan', 1);
my $p5 = Inline::Perl5.new;
$p5.call('print', 'Hello World');
$p5.use('Test::More');
$p5.call('Test::More::plan', 1);
```
## Create a Perl 5 object
@@ -56,9 +56,9 @@ constructor (usually called "new").
```
use Inline::Perl5;
my $i = Inline::Perl5.new;
$i.use('Data::Dumper');
my $dumper = $i.invoke('Data::Dumper', 'new');
my $p5 = Inline::Perl5.new;
$p5.use('Data::Dumper');
my $dumper = $p5.invoke('Data::Dumper', 'new');
```
## Invoke a method on a Perl 5 object
@@ -68,9 +68,9 @@ object. You can call methods on it like on any other object.
```
use Inline::Perl5;
my $i = Inline::Perl5.new;
$i.use('IO::Compress::Bzip2');
my $bzip2 = $i.invoke('IO::Compress::Bzip2', 'new', '/tmp/foo.bz2');
my $p5 = Inline::Perl5.new;
$p5.use('IO::Compress::Bzip2');
my $bzip2 = $p5.invoke('IO::Compress::Bzip2', 'new', '/tmp/foo.bz2');
$bzip2.print($data);
$bzip2.close;
```
@@ -82,9 +82,9 @@ objects in Perl 5, so you can invoke methods using the -> operator.
```
use Inline::Perl5;
my $i = Inline::Perl5.new;
my $p5 = Inline::Perl5.new;
$i.run(q'
$p5.run(q'
sub test {
my ($perl6) = @_;
$perl6->hello;
@@ -97,7 +97,7 @@ objects in Perl 5, so you can invoke methods using the -> operator.
}
}
$i.call('test', Foo.new);
$p5.call('test', Foo.new);
```
## Run arbitrary Perl 5 code
@@ -107,9 +107,9 @@ It accepts Perl 5 code as a string.
```
use Inline::Perl5;
my $i = Inline::Perl5.new;
my $p5 = Inline::Perl5.new;
$i.run(q'
$p5.run(q'
sub test {
return 'Hello from Perl 5';
}
@@ -124,7 +124,7 @@ Pass the Inline::Perl5 object as named parameter to your classes constructor
when creating objects.
```
$i.run(q:heredoc/PERL5/);
$p5.run(q:heredoc/PERL5/);
package Foo;
@@ -143,8 +143,8 @@ when creating objects.
}
use Inline::Perl5;
my $i = Inline::Perl5.new;
say Bar.new(perl5 => $i).test;
my $p5 = Inline::Perl5.new;
say Bar.new(perl5 => $p5).test;
```
# BUILDING
View
@@ -4,8 +4,8 @@
use lib 'lib';
use Inline::Perl5;
my $i = Inline::Perl5.new();
say $i.run('
my $p5 = Inline::Perl5.new();
say $p5.run('
use 5.10.0;
STDOUT->autoflush(1);
@@ -18,8 +18,8 @@ sub test {
5');
print 'It is now ';
$i.call('main::test');
$p5.call('main::test');
$i.DESTROY;
$p5.DESTROY;
# vim: ft=perl6
View
@@ -5,8 +5,8 @@ use Inline::Perl5;
say "1..12";
my $i = Inline::Perl5.new();
say $i.run('
my $p5 = Inline::Perl5.new();
say $p5.run('
use 5.10.0;
$| = 1;
@@ -99,16 +99,16 @@ sub sum {
}
');
$i.call('test');
$i.call('test_int_params', 2, 1);
$i.call('test_str_params', 'Hello', 'Perl 5');
if ($i.call('test_int_retval') == 1) {
$p5.call('test');
$p5.call('test_int_params', 2, 1);
$p5.call('test_str_params', 'Hello', 'Perl 5');
if ($p5.call('test_int_retval') == 1) {
say "ok 4 - return one int";
}
else {
say "not ok 4 - return one int";
}
my @retvals = $i.call('test_int_retvals');
my @retvals = $p5.call('test_int_retvals');
if (@retvals == 3 and @retvals[0] == 3 and @retvals[1] == 1 and @retvals[2] == 2) {
say "ok 5 - return one int";
}
@@ -117,13 +117,13 @@ else {
say " got: {@retvals}";
say " expected: 3, 1, 2";
}
if ($i.call('test_str_retval') eq 'Hello Perl 6!') {
if ($p5.call('test_str_retval') eq 'Hello Perl 6!') {
say "ok 6 - return one string";
}
else {
say "not ok 6 - return one string";
}
@retvals = $i.call('test_mixed_retvals');
@retvals = $p5.call('test_mixed_retvals');
if (@retvals == 3 and @retvals[0] eq 'Hello' and @retvals[1] eq 'Perl' and @retvals[2] == 6) {
say "ok 7 - return mixed values";
}
@@ -133,41 +133,41 @@ else {
say " expected: 'Hello', 'Perl', 6";
}
if ($i.call('Foo::new', 'Foo', 1).test() == 1) {
if ($p5.call('Foo::new', 'Foo', 1).test() == 1) {
say "ok 8 - Perl 5 method call";
}
else {
say "not ok 8 - Perl 5 method call";
}
if ($i.call('Foo::new', 'Foo', 1).sum(3, 1) == 4) {
if ($p5.call('Foo::new', 'Foo', 1).sum(3, 1) == 4) {
say "ok 9 - Perl 5 method call with parameters";
}
else {
say "not ok 9 - Perl 5 method call with parameters";
}
if ($i.call('test_undef', 'main', Any) == 1) {
if ($p5.call('test_undef', 'main', Any) == 1) {
say "ok 10 - Any converted to undef";
}
else {
say "not ok 10 - Any converted to undef";
}
if ($i.call('test_hash', 'main', {a => 2, b => {c => [4, 3]}}) == 1) {
if ($p5.call('test_hash', 'main', {a => 2, b => {c => [4, 3]}}) == 1) {
say "ok 11 - Passing hashes to Perl 5";
}
else {
say "not ok 11 - Passing hashes to Perl 5";
}
if ($i.call('test_foo', 'main', $i.call('Foo::new', 'Foo', 6)) == 6) {
if ($p5.call('test_foo', 'main', $p5.call('Foo::new', 'Foo', 6)) == 6) {
say "ok 12 - Passing Perl 5 objects back from Perl 6";
}
else {
say "not ok 12 - Passing Perl 5 objects back from Perl 6";
}
$i.DESTROY;
$p5.DESTROY;
# vim: ft=perl6
View
@@ -3,8 +3,8 @@
use v6;
use Inline::Perl5;
my $i = Inline::Perl5.new();
$i.run(q/
my $p5 = Inline::Perl5.new();
$p5.run(q/
use Test::More;
sub test {
@@ -26,13 +26,13 @@ class Foo {
my $foo = Foo.new;
$i.call('test', $foo);
$p5.call('test', $foo);
$i.run(q/
$p5.run(q/
done_testing;
/);
$i.DESTROY;
$p5.DESTROY;
# vim: ft=perl6
View
@@ -5,19 +5,19 @@ use Inline::Perl5;
say '1..2';
my $i = Inline::Perl5.new();
my $p5 = Inline::Perl5.new();
$i.run('
$p5.run('
use 5.10.0;
say "ok 1 - basic eval";
');
$i.run('
$p5.run('
use 5.10.0;
use Fcntl;
say "ok 2 - loading XS modules";
');
$i.DESTROY;
$p5.DESTROY;
# vim: ft=perl6
View
@@ -6,9 +6,9 @@ use Inline::Perl5;
plan 2;
my $i = Inline::Perl5.new();
is $i.run('5;'), 5;
is $i.run('"Perl 5";'), 'Perl 5';
$i.DESTROY;
my $p5 = Inline::Perl5.new();
is $p5.run('5;'), 5;
is $p5.run('"Perl 5";'), 'Perl 5';
$p5.DESTROY;
# vim: ft=perl6
View
@@ -7,15 +7,15 @@ use NativeCall;
plan 5;
my $i = Inline::Perl5.new();
my $p5 = Inline::Perl5.new();
my $has_moose = $i.run('eval { require Moose; 1};');
my $has_moose = $p5.run('eval { require Moose; 1};');
if !$has_moose {
skip('Perl 5 Moose module not available',2);
exit;
}
$i.run(q:heredoc/PERL5/);
$p5.run(q:heredoc/PERL5/);
package Foo;
@@ -66,9 +66,9 @@ class Bar does Inline::Perl5::Perl5Parent['Foo'] {
}
is(Bar.new(perl5 => $i).test, 'Perl6');
is(Bar.new(perl5 => $i).test_inherited, 'Perl5');
is(Bar.new(perl5 => $i).foo, 'Moose!');
is(Bar.new(perl5 => $p5).test, 'Perl6');
is(Bar.new(perl5 => $p5).test_inherited, 'Perl5');
is(Bar.new(perl5 => $p5).foo, 'Moose!');
class Baz does Inline::Perl5::Perl5Parent['Foo'] {
method bar {
@@ -77,7 +77,7 @@ class Baz does Inline::Perl5::Perl5Parent['Foo'] {
}
is(Baz.new(perl5 => $i).test, 'Perl6!');
is(Baz.new(perl5 => $p5).test, 'Perl6!');
class Qux does Inline::Perl5::Perl5Parent['Bar'] {
method qux {
@@ -86,7 +86,7 @@ class Qux does Inline::Perl5::Perl5Parent['Bar'] {
}
is(Qux.new(perl5 => $i).test, 'Perl6!!');
is(Qux.new(perl5 => $p5).test, 'Perl6!!');
# vim: ft=perl6
View
@@ -4,18 +4,18 @@ use v6;
use Test;
use Inline::Perl5;
my $i = Inline::Perl5.new();
my $p5 = Inline::Perl5.new();
is $i.run('5'), 5;
is $i.run('"Perl 5"'), 'Perl 5';
is_deeply $i.run('[1, 2]'), [1, 2];
is_deeply $i.run('[1, [2, 3]]'), [1, [2, 3]];
is_deeply $i.run('{a => 1, b => 2}'), {a => 1, b => 2};
is_deeply $i.run('{a => 1, b => {c => 3}}'), {a => 1, b => {c => 3}};
is_deeply $i.run('[1, {b => {c => 3}}]'), [1, {b => {c => 3}}];
ok $i.run('undef') === Any, 'p5 undef maps to p6 Any';
is $p5.run('5'), 5;
is $p5.run('"Perl 5"'), 'Perl 5';
is_deeply $p5.run('[1, 2]'), [1, 2];
is_deeply $p5.run('[1, [2, 3]]'), [1, [2, 3]];
is_deeply $p5.run('{a => 1, b => 2}'), {a => 1, b => 2};
is_deeply $p5.run('{a => 1, b => {c => 3}}'), {a => 1, b => {c => 3}};
is_deeply $p5.run('[1, {b => {c => 3}}]'), [1, {b => {c => 3}}];
ok $p5.run('undef') === Any, 'p5 undef maps to p6 Any';
$i.DESTROY;
$p5.DESTROY;
done;
Oops, something went wrong.

0 comments on commit cc683da

Please sign in to comment.