# HG changeset patch # User Mike Miller # Date 1468569083 25200 # Node ID 377f2dc057ea22f9bf82d52ea0274f4bc0e83b2f # Parent d6c44d68048219bc38b7a40367f50adae0aba7d3 pycall: add more tests for preservation of values to and from Python * pycall.cc: Test the round trip path into and out of Python for certain Octave value types. diff -r d6c44d680482 -r 377f2dc057ea pycall.cc --- a/pycall.cc Thu Jul 14 23:56:40 2016 -0700 +++ b/pycall.cc Fri Jul 15 00:51:23 2016 -0700 @@ -221,6 +221,15 @@ %!assert (pycall ("typename", "Hello world"), "str") %!assert (pycall ("typename", char ([1, 2, 3])), "str") +## Test round trip type preservation / conversion +%!test +%! pyexec ("def roundtrip(x): return x"); +%! values = { 0, pi, 2j, eps, false, true, version, "Hello world", ... +%! [1, 2, 3], eye (4) }; +%! for i = 1:numel (values) +%! assert (pycall ("roundtrip", values{i}), values{i}); +%! endfor + %!error %! pyexec ("def intwrapper(x):\n return int(x)\n"); %! pycall ("intwrapper", ftp ());