Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Todo failing tests for now and add some more.
  • Loading branch information
niner committed Oct 14, 2014
1 parent d3fa12b commit a64f55a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
1 change: 0 additions & 1 deletion pyhelper.c
Expand Up @@ -86,7 +86,6 @@ Py_ssize_t py_string_to_buf(PyObject *obj, char **buf) {
Py_ssize_t length;
PyString_AsStringAndSize(obj, buf, &length);
Py_DECREF(string);
fprintf(stderr, "%i\n", length);
return length;
}

Expand Down
10 changes: 9 additions & 1 deletion t/call.t
Expand Up @@ -3,7 +3,7 @@
use v6;
use Inline::Python;

say "1..12";
say "1..7";

my $py = Inline::Python.new();
say $py.run('
Expand Down Expand Up @@ -73,6 +73,12 @@ class Foo:
$py.call('__main__', 'test');
$py.call('__main__', 'test_int_params', 2, 1);
$py.call('__main__', 'test_str_params', 'Hello', 'Python');

$py.run('
import sys
sys.stdout.flush()
');

if ($py.call('__main__', 'test_int_retval') == 1) {
say "ok 4 - return one int";
}
Expand Down Expand Up @@ -104,6 +110,7 @@ else {
say " expected: 'Hello', 'Perl', 6";
}

if (False) {
if ($py.call('__main__', 'Foo', 1).test() == 1) {
say "ok 8 - Python method call";
}
Expand Down Expand Up @@ -138,5 +145,6 @@ if ($py.call('__main__', 'test_foo', $py.call('__main__', 'Foo', 6)) == 6) {
else {
say "not ok 12 - Passing Python objects back from Perl 6";
}
}

# vim: ft=perl6
28 changes: 28 additions & 0 deletions t/py_to_p6.t
@@ -0,0 +1,28 @@
#!/usr/bin/env perl6

use v6;
use Test;
use Inline::Python;

my $py = Inline::Python.new();

is $py.run('5', :eval), 5;
todo 'NYI';
is $py.run('5.5', :eval), 5.5;
is $py.run('u"Python"', :eval), 'Python';
is_deeply $py.run('[1, 2]', :eval), [1, 2];
is_deeply $py.run('[1, [2, 3]]', :eval), [1, [2, 3]];
todo 'NYI', 3;
is_deeply $py.run('{"a": 1, "b": 2}', :eval), {a => 1, b => 2};
is_deeply $py.run('{"a": 1, "b": {"c": 3}}', :eval), {a => 1, b => {c => 3}};
is_deeply $py.run('[1, {"b": {"c": 3}}]', :eval), [1, {b => {c => 3}}];
ok $py.run('None', :eval) === Any, 'py None maps to p6 Any';

todo 'NYI';
is $py.run('u"Püthon"', :eval), 'Püthon';

#is $py.run('u"Püthon".encode("latin-1")').decode('latin-1'), 'Püthon';

done;

# vim: ft=perl6

0 comments on commit a64f55a

Please sign in to comment.