Mercurial > octave
annotate test/nest/nest.tst @ 29359:7854d5752dd2
maint: merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 10 Feb 2021 10:10:40 -0500 |
parents | 0998695317d8 0a5b15007766 |
children | 76269aa97398 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29343
diff
changeset
|
3 ## Copyright (C) 2006-2021 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26946
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
7 ## |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
8 ## This file is part of Octave. |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
9 ## |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23850
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23850
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
14 ## |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
15 ## Octave is distributed in the hope that it will be useful, but |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
19 ## |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
20 ## You should have received a copy of the GNU General Public License |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23850
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
25 |
14548
604696c3ff93
maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents:
14544
diff
changeset
|
26 ################################################################################ |
604696c3ff93
maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents:
14544
diff
changeset
|
27 ## This file actually executes the tests on nested functions. |
604696c3ff93
maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents:
14544
diff
changeset
|
28 ## |
604696c3ff93
maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents:
14544
diff
changeset
|
29 ## It relies on the function files defined in the nest/ directory. |
604696c3ff93
maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents:
14544
diff
changeset
|
30 ################################################################################ |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
31 |
26182
34617dd78f02
avoid possible leaked global variables in tests
John W. Eaton <jwe@octave.org>
parents:
25111
diff
changeset
|
32 %!test |
34617dd78f02
avoid possible leaked global variables in tests
John W. Eaton <jwe@octave.org>
parents:
25111
diff
changeset
|
33 %! assert (recursive_nest (), 25) |
34617dd78f02
avoid possible leaked global variables in tests
John W. Eaton <jwe@octave.org>
parents:
25111
diff
changeset
|
34 %! clear -global recursive_nest_inc; # cleanup after test |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
35 |
14548
604696c3ff93
maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents:
14544
diff
changeset
|
36 %!assert (recursive_nest2 (), 20) |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
37 |
14548
604696c3ff93
maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents:
14544
diff
changeset
|
38 %!assert (recursive_nest3 (), 5) |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
39 |
28525
286fe9352cd6
Interpreter errors on unassigned inputs (bug #58686)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
28195
diff
changeset
|
40 ## FIXME: The following test works in Matlab R2020b, but in Octave it never |
286fe9352cd6
Interpreter errors on unassigned inputs (bug #58686)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
28195
diff
changeset
|
41 ## worked. The output of "script_nest" is unassigned. This got |
286fe9352cd6
Interpreter errors on unassigned inputs (bug #58686)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
28195
diff
changeset
|
42 ## revealed by fixing bug #58686. |
286fe9352cd6
Interpreter errors on unassigned inputs (bug #58686)
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
28195
diff
changeset
|
43 |
28579
713398d4a3c3
update bug status of tests marked with bug numbers
John W. Eaton <jwe@octave.org>
parents:
28529
diff
changeset
|
44 %!xtest <*58691> assert (script_nest (), 5) |
14548
604696c3ff93
maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents:
14544
diff
changeset
|
45 |
604696c3ff93
maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents:
14544
diff
changeset
|
46 %!assert (arg_ret (), 10) |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
47 |
14548
604696c3ff93
maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents:
14544
diff
changeset
|
48 %!assert (arg_nest, 1) |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
49 |
14548
604696c3ff93
maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents:
14544
diff
changeset
|
50 %!assert (varg_nest (-1), 6) |
604696c3ff93
maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents:
14544
diff
changeset
|
51 |
604696c3ff93
maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents:
14544
diff
changeset
|
52 %!assert (varg_nest2, 5) |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
53 |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
54 %!test |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
55 %! scope0; |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
56 |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
57 %!test |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
58 %! scope1 (1); |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
59 |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
60 %!test |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
61 %! scope3; |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff
changeset
|
62 |
21317
a4faec57f4c8
maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
63 %!assert (nest_eval ("x = 5;", "x = 6;"), 6) |
23850
4b0e0cae49db
disallow dynamic variable creation in static scopes (bug #51698)
John W. Eaton <jwe@octave.org>
parents:
23598
diff
changeset
|
64 |
4b0e0cae49db
disallow dynamic variable creation in static scopes (bug #51698)
John W. Eaton <jwe@octave.org>
parents:
23598
diff
changeset
|
65 %!error <can not add variable "y" to a static workspace> |
4b0e0cae49db
disallow dynamic variable creation in static scopes (bug #51698)
John W. Eaton <jwe@octave.org>
parents:
23598
diff
changeset
|
66 %! nest_eval ("x = 5;", "y = 6;"); |
4b0e0cae49db
disallow dynamic variable creation in static scopes (bug #51698)
John W. Eaton <jwe@octave.org>
parents:
23598
diff
changeset
|
67 |
4b0e0cae49db
disallow dynamic variable creation in static scopes (bug #51698)
John W. Eaton <jwe@octave.org>
parents:
23598
diff
changeset
|
68 %!error <can not add variable "y" to a static workspace> |
4b0e0cae49db
disallow dynamic variable creation in static scopes (bug #51698)
John W. Eaton <jwe@octave.org>
parents:
23598
diff
changeset
|
69 %! nest_eval ("x = -5; x = abs (x);", "y = 6;") |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
14548
diff
changeset
|
70 |
23598
287b07229aff
update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
71 %!test |
287b07229aff
update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
72 %! f = no_closure (0); |
287b07229aff
update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
73 %! assert (f("foo"), "nested foo"); |
287b07229aff
update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
74 %! assert (f("foo"), "nested foo"); |
287b07229aff
update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
75 |
26946
04e5cb5e2cb3
update bug status in tests
John W. Eaton <jwe@octave.org>
parents:
26860
diff
changeset
|
76 %!test <*39257> |
23598
287b07229aff
update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
77 %! f = no_closure (1); |
287b07229aff
update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
78 %! assert (f(), "nested"); |
287b07229aff
update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
79 %! assert (f("foo"), "nested foo"); |
287b07229aff
update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
80 |
14548
604696c3ff93
maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents:
14544
diff
changeset
|
81 %!error <D' undefined near line 7> scope2 |
15236
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
14548
diff
changeset
|
82 %!error <can not add variable "y" to a static workspace> nest_eval ("y = 5;", "") |
44d6ffdf9479
Disallow new variables in nested functions (bug #36271)
Max Brister <max@2bass.com>
parents:
14548
diff
changeset
|
83 %!error <can not add variable "y" to a static workspace> nest_eval ("y;", "") |
26825
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
84 |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
85 ## Test the way that non-local variables referenced by nested functions |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
86 ## work with function handles. |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
87 |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
88 ## FH1 and FH2 were created separately so will have distinct |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
89 ## closure contexts.handles, FH3 is a copy of FH2 so they will |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
90 ## share the same context. |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
91 |
26946
04e5cb5e2cb3
update bug status in tests
John W. Eaton <jwe@octave.org>
parents:
26860
diff
changeset
|
92 %!test <*39257> |
26825
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
93 %! fh1 = nst1 (13); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
94 %! fh2 = nst1 (13); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
95 %! fh3 = fh2; |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
96 %! |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
97 %! assert (fh1 (), 13); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
98 %! assert (fh2 (), 13); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
99 %! assert (fh3 (), 13); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
100 %! |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
101 %! assert (fh1 (42), 42); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
102 %! assert (fh2 (), 13); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
103 %! assert (fh3 (), 13); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
104 %! |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
105 %! assert (fh2 (pi), pi); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
106 %! assert (fh1 (), 42); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
107 %! assert (fh3 (), pi); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
108 |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
109 ## Similar to the test above, but with persistent variables. These are |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
110 ## stored in the function, not the closure context, so are shared among |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
111 ## all handles whether they are created separately or copied. |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
112 |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
113 %!test |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
114 %! fh1 = nst2 (13); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
115 %! fh2 = nst2 (13); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
116 %! fh3 = fh2; |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
117 %! |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
118 %! assert (fh1 (), 13); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
119 %! assert (fh2 (), 13); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
120 %! assert (fh3 (), 13); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
121 %! |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
122 %! assert (fh1 (42), 42); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
123 %! assert (fh2 (), 42); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
124 %! assert (fh3 (), 42); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
125 %! |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
126 %! assert (fh2 (pi), pi); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
127 %! assert (fh1 (), pi); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
128 %! assert (fh3 (), pi); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
129 |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
130 ## And again with global variables. |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
131 |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
132 %!test |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
133 %! fh1 = nst3 (13); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
134 %! fh2 = nst3 (13); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
135 %! fh3 = fh2; |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
136 %! |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
137 %! assert (fh1 (), 13); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
138 %! assert (fh2 (), 13); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
139 %! assert (fh3 (), 13); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
140 %! |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
141 %! assert (fh1 (42), 42); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
142 %! assert (fh2 (), 42); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
143 %! assert (fh3 (), 42); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
144 %! |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
145 %! assert (fh2 (pi), pi); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
146 %! assert (fh1 (), pi); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
147 %! assert (fh3 (), pi); |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
148 %! |
6e9034836239
allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
149 %! clear -global g; # cleanup after tests |
26860
7c9a681c4474
Add fixed test BIST for nested functions (bug #39257).
Rik <rik@octave.org>
parents:
26825
diff
changeset
|
150 |
7c9a681c4474
Add fixed test BIST for nested functions (bug #39257).
Rik <rik@octave.org>
parents:
26825
diff
changeset
|
151 ## Test case from <https://stackoverflow.com/q/26238491/6579744> |
7c9a681c4474
Add fixed test BIST for nested functions (bug #39257).
Rik <rik@octave.org>
parents:
26825
diff
changeset
|
152 %!test |
7c9a681c4474
Add fixed test BIST for nested functions (bug #39257).
Rik <rik@octave.org>
parents:
26825
diff
changeset
|
153 %! f1 = counter (); |
7c9a681c4474
Add fixed test BIST for nested functions (bug #39257).
Rik <rik@octave.org>
parents:
26825
diff
changeset
|
154 %! f2 = counter (); |
7c9a681c4474
Add fixed test BIST for nested functions (bug #39257).
Rik <rik@octave.org>
parents:
26825
diff
changeset
|
155 %! observed = [f1(), f1(), f2(), f1(), f2()]; |
7c9a681c4474
Add fixed test BIST for nested functions (bug #39257).
Rik <rik@octave.org>
parents:
26825
diff
changeset
|
156 %! assert (observed, [1, 2, 1, 3, 2]); |
28195
7567413e7246
test for visibility of nested function in scripts called from parent function
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
157 |
7567413e7246
test for visibility of nested function in scripts called from parent function
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
158 ## Test visibility of nested function from script called from parent. |
28907
11f1207111c5
maint: Don't use semicolon at end of single-line BIST tests.
Rik <rik@octave.org>
parents:
28579
diff
changeset
|
159 %!assert (script_nest_2 (42), 84) |
28195
7567413e7246
test for visibility of nested function in scripts called from parent function
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
160 %!error script_nest_2 (0) |
29343
4de13dc0eff2
fix symbol lookup issue with anonymous functions (bug #55989)
John W. Eaton <jwe@octave.org>
parents:
28579
diff
changeset
|
161 |
4de13dc0eff2
fix symbol lookup issue with anonymous functions (bug #55989)
John W. Eaton <jwe@octave.org>
parents:
28579
diff
changeset
|
162 %!assert (bug_59989 (), 6) |