annotate test/inline-fcn.tst @ 33608:5fba13104493 bytecode-interpreter tip

maint: merge default to bytecode-interpreter.
author Nicholas R. Jankowski <jankowski.nicholas@gmail.com>
date Sat, 18 May 2024 22:40:00 -0400
parents cf60f8f636f6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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)
28916
ec591c500fa4 maint: Use Octave convention of space after function name in test/.
Rik <rik@octave.org>
parents: 28427
diff changeset
9 %!assert (feval (inline ("exp (P1*x) + P2", 3), 3, 4, 5), exp (3*4) + 5)
28427
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")
30031
cf60f8f636f6 Start deprecation of Fortran exponentiation operator.
Rik <rik@octave.org>
parents: 28916
diff changeset
33 %!assert (formula (vectorize (inline ("2^x^5"))), "2.^x.^5")