Mercurial > octave
view test/inline-fcn.tst @ 30103:55eeb7f0850b stable
store parent name in function object when caching parents in scope (bug #61105)
* symscope.h, symscope.cc (symbol_scope_rep::cache_parent_fcn_names):
Also store parent function name in function object.
* bug-61105/bug-61105.tst, bug-61105/nested_test_1.m,
bug-61105/nested_test_2.m, bug-61105/nested_test_3.m: New test files.
* test/bug-61105/module.mk: New file.
* test/module.mk: Update.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 01 Sep 2021 16:19:09 -0400 |
parents | 7a8c69c4eb55 |
children | ec591c500fa4 |
line wrap: on
line source
## INLINE contstructor %!shared fn %! fn = inline ("x.^2 + 1"); %!assert (feval (fn, 6), 37) %!assert (fn (6), 37) %!assert (feval (inline ("sum (x(:))"), [1 2; 3 4]), 10) %!assert (feval (inline ("sqrt (x^2 + y^2)", "x", "y"), 3, 4), 5) %!assert (feval (inline ("exp (P1*x) + P2", 3), 3, 4, 5), exp(3*4) + 5) ## Test input validation %!error inline () %!error <EXPR must be a string> inline (1) %!error <N must be an integer> inline ("2", ones (2,2)) %!error <N must be a positive integer> inline ("2", -1) %!error <additional arguments must be strings> inline ("2", "x", -1, "y") ## FORMULA %!assert (formula (fn), "x.^2 + 1") %!assert (formula (fn), char (fn)) ## ARGNAMES %!assert (argnames (fn), {"x"}) %!assert (argnames (inline ("1e-3*y + 2e4*z")), {"y"; "z"}) %!assert (argnames (inline ("2", 2)), {"x"; "P1"; "P2"}) ## VECTORIZE %!assert (formula (vectorize (fn)), "x.^2 + 1") %!assert (formula (vectorize (inline ("1e-3*y + 2e4*z"))), "1e-3.*y + 2e4.*z") %!assert (formula (vectorize (inline ("2**x^5"))), "2.**x.^5")