annotate test/nest/nest.tst @ 28195:7567413e7246 stable

test for visibility of nested function in scripts called from parent function * nest.tst: New tests.
author John W. Eaton <jwe@octave.org>
date Wed, 08 Apr 2020 15:59:56 -0400
parents bd51beb6205e
children 286fe9352cd6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 ##
27919
1891570abac8 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27918
diff changeset
3 ## Copyright (C) 2006-2020 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
14548
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
40 %!assert (script_nest (), 5)
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
41
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
42 %!assert (arg_ret (), 10)
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
43
14548
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
44 %!assert (arg_nest, 1)
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
45
14548
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
46 %!assert (varg_nest (-1), 6)
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
47
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
48 %!assert (varg_nest2, 5)
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
49
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
50 %!test
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
51 %! scope0;
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
52
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
53 %!test
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
54 %! scope1 (1);
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
55
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
56 %!test
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
57 %! scope3;
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
58
21317
a4faec57f4c8 maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
59 %!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
60
4b0e0cae49db disallow dynamic variable creation in static scopes (bug #51698)
John W. Eaton <jwe@octave.org>
parents: 23598
diff changeset
61 %!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
62 %! 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
63
4b0e0cae49db disallow dynamic variable creation in static scopes (bug #51698)
John W. Eaton <jwe@octave.org>
parents: 23598
diff changeset
64 %!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
65 %! 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
66
23598
287b07229aff update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
67 %!test
287b07229aff update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
68 %! f = no_closure (0);
287b07229aff update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
69 %! assert (f("foo"), "nested foo");
287b07229aff update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
70 %! assert (f("foo"), "nested foo");
287b07229aff update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
71
26946
04e5cb5e2cb3 update bug status in tests
John W. Eaton <jwe@octave.org>
parents: 26860
diff changeset
72 %!test <*39257>
23598
287b07229aff update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
73 %! f = no_closure (1);
287b07229aff update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
74 %! assert (f(), "nested");
287b07229aff update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
75 %! assert (f("foo"), "nested foo");
287b07229aff update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
76
14548
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
77 %!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
78 %!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
79 %!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
80
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
81 ## 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
82 ## work with function handles.
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
83
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
84 ## 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
85 ## 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
86 ## share the same context.
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
87
26946
04e5cb5e2cb3 update bug status in tests
John W. Eaton <jwe@octave.org>
parents: 26860
diff changeset
88 %!test <*39257>
26825
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
89 %! fh1 = nst1 (13);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
90 %! fh2 = nst1 (13);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
91 %! fh3 = fh2;
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
92 %!
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
93 %! assert (fh1 (), 13);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
94 %! assert (fh2 (), 13);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
95 %! assert (fh3 (), 13);
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 (42), 42);
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 (fh2 (pi), pi);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
102 %! assert (fh1 (), 42);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
103 %! assert (fh3 (), pi);
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 ## 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
106 ## 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
107 ## 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
108
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
109 %!test
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
110 %! fh1 = nst2 (13);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
111 %! fh2 = nst2 (13);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
112 %! fh3 = fh2;
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
113 %!
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
114 %! assert (fh1 (), 13);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
115 %! assert (fh2 (), 13);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
116 %! assert (fh3 (), 13);
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 (42), 42);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
119 %! assert (fh2 (), 42);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
120 %! assert (fh3 (), 42);
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 (fh2 (pi), pi);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
123 %! assert (fh1 (), pi);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
124 %! assert (fh3 (), pi);
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 ## 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
127
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
128 %!test
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
129 %! fh1 = nst3 (13);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
130 %! fh2 = nst3 (13);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
131 %! fh3 = fh2;
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
132 %!
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
133 %! assert (fh1 (), 13);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
134 %! assert (fh2 (), 13);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
135 %! assert (fh3 (), 13);
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 (42), 42);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
138 %! assert (fh2 (), 42);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
139 %! assert (fh3 (), 42);
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 (fh2 (pi), pi);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
142 %! assert (fh1 (), pi);
6e9034836239 allow handles to nested functions to work (bug #39257)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
143 %! assert (fh3 (), pi);
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 %! 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
146
7c9a681c4474 Add fixed test BIST for nested functions (bug #39257).
Rik <rik@octave.org>
parents: 26825
diff changeset
147 ## 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
148 %!test
7c9a681c4474 Add fixed test BIST for nested functions (bug #39257).
Rik <rik@octave.org>
parents: 26825
diff changeset
149 %! f1 = counter ();
7c9a681c4474 Add fixed test BIST for nested functions (bug #39257).
Rik <rik@octave.org>
parents: 26825
diff changeset
150 %! f2 = counter ();
7c9a681c4474 Add fixed test BIST for nested functions (bug #39257).
Rik <rik@octave.org>
parents: 26825
diff changeset
151 %! observed = [f1(), f1(), f2(), f1(), f2()];
7c9a681c4474 Add fixed test BIST for nested functions (bug #39257).
Rik <rik@octave.org>
parents: 26825
diff changeset
152 %! 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
153
7567413e7246 test for visibility of nested function in scripts called from parent function
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
154 ## Test visibility of nested function from script called from parent.
7567413e7246 test for visibility of nested function in scripts called from parent function
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
155 %!assert (script_nest_2 (42), 84);
7567413e7246 test for visibility of nested function in scripts called from parent function
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
156 %!error script_nest_2 (0)