changeset 198:377f2dc057ea

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.
author Mike Miller <mtmiller@octave.org>
date Fri, 15 Jul 2016 00:51:23 -0700
parents d6c44d680482
children 0c6f7ae8a95b 6fffa6219b2c
files pycall.cc
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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 <argument type conversion>
 %! pyexec ("def intwrapper(x):\n    return int(x)\n");
 %! pycall ("intwrapper", ftp ());