annotate test/nest/nest.tst @ 25054:6652d3823428 stable

maint: Update copyright dates in all source files.
author John W. Eaton <jwe@octave.org>
date Fri, 30 Mar 2018 09:19:05 -0400
parents 194eb4bd202b
children daff5efe062f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25054
6652d3823428 maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1 ## Copyright (C) 2006-2018 John W. Eaton
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
2 ##
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
3 ## This file is part of Octave.
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
4 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23850
diff changeset
5 ## 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
6 ## 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
7 ## 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
8 ## (at your option) any later version.
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
9 ##
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
10 ## 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
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## GNU General Public License for more details.
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 ## 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
16 ## 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
17 ## <https://www.gnu.org/licenses/>.
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
18
14548
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
19 ################################################################################
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
20 ## 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
21 ##
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
22 ## 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
23 ################################################################################
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
24
14548
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
25 %!assert (recursive_nest (), 25)
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
26
14548
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
27 %!assert (recursive_nest2 (), 20)
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
28
14548
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
29 %!assert (recursive_nest3 (), 5)
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
30
14548
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
31 %!assert (script_nest (), 5)
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
32
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
33 %!assert (arg_ret (), 10)
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
34
14548
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
35 %!assert (arg_nest, 1)
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
36
14548
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
37 %!assert (varg_nest (-1), 6)
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
38
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
39 %!assert (varg_nest2, 5)
14544
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
40
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
41 %!test
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
42 %! scope0;
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
43
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
44 %!test
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
45 %! scope1 (1);
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
46
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
47 %!test
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
48 %! scope3;
be18c9e359bf Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
diff changeset
49
21317
a4faec57f4c8 maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
50 %!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
51
4b0e0cae49db disallow dynamic variable creation in static scopes (bug #51698)
John W. Eaton <jwe@octave.org>
parents: 23598
diff changeset
52 %!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
53 %! 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
54
4b0e0cae49db disallow dynamic variable creation in static scopes (bug #51698)
John W. Eaton <jwe@octave.org>
parents: 23598
diff changeset
55 %!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
56 %! 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
57
23598
287b07229aff update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
58 %!test
287b07229aff update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
59 %! f = no_closure (0);
287b07229aff update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
60 %! assert (f("foo"), "nested foo");
287b07229aff update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
61 %! assert (f("foo"), "nested foo");
287b07229aff update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
62
287b07229aff update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
63 %!test <39257>
287b07229aff update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
64 %! f = no_closure (1);
287b07229aff update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
65 %! assert (f(), "nested");
287b07229aff update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
66 %! assert (f("foo"), "nested foo");
287b07229aff update test for handles to nested functions
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
67
14548
604696c3ff93 maint: Add missing test/nest files to build system.
Rik <octave@nomad.inbox5.com>
parents: 14544
diff changeset
68 %!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
69 %!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
70 %!error <can not add variable "y" to a static workspace> nest_eval ("y;", "")