Mercurial > pytave
changeset 180:5f0d94afebe2
Added some basic tests
* pyeval.cc: 3 BIST tests added
* pycall.cc: 1 BIST test added
author | Abhinav Tripathi <genuinelucifer@gmail.com> |
---|---|
date | Sat, 04 Jun 2016 11:19:49 -0700 |
parents | 9aeb3cd4a288 |
children | fa76167d5929 |
files | pycall.cc pyeval.cc |
diffstat | 2 files changed, 28 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/pycall.cc Sun May 29 08:51:35 2016 -0700 +++ b/pycall.cc Sat Jun 04 11:19:49 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 Sun May 29 08:51:35 2016 -0700 +++ b/pyeval.cc Sat Jun 04 11:19:49 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) +*/