changeset 181:fa76167d5929

Merge unit tests for py* functions
author Mike Miller <mtmiller@octave.org>
date Sat, 04 Jun 2016 12:50:50 -0700
parents c05ff3e85fec (current diff) 5f0d94afebe2 (diff)
children 0bf4b7cf16ee
files
diffstat 2 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/pycall.cc	Sat Jun 04 06:05:48 2016 -0700
+++ b/pycall.cc	Sat Jun 04 12:50:50 2016 -0700
@@ -181,3 +181,10 @@
   return retval;
 }
 
+/*
+%!test
+%! pyexec (strjoin({'def pyfunc(x):',
+%!                 '    return 2*x'}, '\n'));
+%! z = pycall ('pyfunc', [20 20]);
+%! assert (z == [40 40])
+*/
--- a/pyeval.cc	Sat Jun 04 06:05:48 2016 -0700
+++ b/pyeval.cc	Sat Jun 04 12:50:50 2016 -0700
@@ -103,3 +103,24 @@
 
   return retval;
 }
+
+/*
+%!test
+%! q = pyeval ('10.1')
+%! assert (isnumeric(q))
+%! % note: floating-point equality test: usually bad but here we expect the exact same float
+%! assert (q, 10.1)
+
+%!test
+%! q = pyeval ('"I <3 Octave"')
+%! assert (ischar (q))
+%! assert (~strcmp (q, '1 <3 Octave'))
+
+%!test
+%! % This might change if we stop converting lists
+%! z = pyeval ('[1, [21, 22], 3, [41, [421, 422], 43]]');
+%! assert (z{2}{1} == 21)
+%! assert (z{2}{2} == 22)
+%! assert (z{4}{2}{1} == 421)
+%! assert (z{4}{2}{2} == 422)
+*/