Mercurial > octave
annotate test/inline-fcn.tst @ 28427:7a8c69c4eb55 stable
convert obsolete octave_fcn_inline object to @inline class
Use a legacy @class object to provide inline function objects instead
of using a built-in class derived from the octave_function_handle
class.
* scripts/legacy/@inline: New directory containing the following
files: argnames.m, char.m, feval.m, formula.m, inline.m, subsref.m,
vectorize.m.
* scripts/legacy/@inline/module.mk: New file.
* scripts/legacy/module.mk, scripts/module.mk: Update.
* test/inline-fcn.tst: New tests.
* test/module.mk: Update.
* ov-fcn-inline.h, ov-fcn-inline.cc: Delete. Remove all uses.
* libinterp/octave-value/module.mk: Update.
* external.txi, func.txi, octave.texi, plot.txi, quad.txi:
Eliminate discusion of inline function objects.
* fplot.m, __ezplot__.m: Use isa to identify inline objects instead of
instead of checking typeinfo.
* ov-fcn-handle.cc, ov-typeinfo.cc: Fix tests.
* ov-base.h, ov-base.cc (octave_base_value::fcn_inline_value): Delete.
* ov.h, ov.cc (octave_value::fcn_inline_value): Delete.
(octave_value::xfcn_inline_value): Delete value extractor.
* ov-class.cc, ov-class.h (octave_inline, octave_inline_fcn):
New classes that allow us to preserve the is_inline_function and
function_value methods that were previously available in the
octave_fcn_inline class.
(F__inline_ctor__): New function for final construction of inline
objects.
* ls-hdf5.cc, ls-mat5.cc, ls-oct-binary.cc, ls-oct-text.cc:
Handle loading of inline function objects from old files as special
cases. New inline function objects will be saved and loaded as
ordinary @class objects.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 23 Mar 2020 15:29:49 -0400 |
parents | |
children | ec591c500fa4 |
rev | line source |
---|---|
28427
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 ## INLINE contstructor |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3 %!shared fn |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 %! fn = inline ("x.^2 + 1"); |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 %!assert (feval (fn, 6), 37) |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 %!assert (fn (6), 37) |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 %!assert (feval (inline ("sum (x(:))"), [1 2; 3 4]), 10) |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
8 %!assert (feval (inline ("sqrt (x^2 + y^2)", "x", "y"), 3, 4), 5) |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 %!assert (feval (inline ("exp (P1*x) + P2", 3), 3, 4, 5), exp(3*4) + 5) |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
10 |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 ## Test input validation |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 %!error inline () |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 %!error <EXPR must be a string> inline (1) |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 %!error <N must be an integer> inline ("2", ones (2,2)) |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 %!error <N must be a positive integer> inline ("2", -1) |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 %!error <additional arguments must be strings> inline ("2", "x", -1, "y") |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
18 ## FORMULA |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
19 |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 %!assert (formula (fn), "x.^2 + 1") |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 %!assert (formula (fn), char (fn)) |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 ## ARGNAMES |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
24 |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 %!assert (argnames (fn), {"x"}) |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 %!assert (argnames (inline ("1e-3*y + 2e4*z")), {"y"; "z"}) |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 %!assert (argnames (inline ("2", 2)), {"x"; "P1"; "P2"}) |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 ## VECTORIZE |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 %!assert (formula (vectorize (fn)), "x.^2 + 1") |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 %!assert (formula (vectorize (inline ("1e-3*y + 2e4*z"))), "1e-3.*y + 2e4.*z") |
7a8c69c4eb55
convert obsolete octave_fcn_inline object to @inline class
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 %!assert (formula (vectorize (inline ("2**x^5"))), "2.**x.^5") |