annotate test/global.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 2e484f9f1f18
children
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 ##
32632
2e484f9f1f18 maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 31706
diff changeset
3 ## Copyright (C) 2006-2024 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
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/>.
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
7 ##
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
8 ## This file is part of Octave.
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
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: 23220
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.
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
14 ##
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
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.
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
19 ##
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
20 ## You should have received a copy of the GNU General Public License
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
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: 23220
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 ########################################################################
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5590
diff changeset
25
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
26 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
27 %! global G = 1;
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
28 %! assert (G,1);
26182
34617dd78f02 avoid possible leaked global variables in tests
John W. Eaton <jwe@octave.org>
parents: 25482
diff changeset
29 %! clear -global G; # cleanup after test
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
30
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
31 %!function f ()
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
32 %! global G;
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
33 %! assert (G,1);
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
34 %!endfunction
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
35 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
36 %! global G = 1;
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
37 %! f;
26182
34617dd78f02 avoid possible leaked global variables in tests
John W. Eaton <jwe@octave.org>
parents: 25482
diff changeset
38 %! clear -global G; # cleanup after test
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
39
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
40 %!function f ()
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
41 %! fail ("G");
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
42 %!endfunction
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
43 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
44 %! global G = 1;
16213
b1283d4c06c2 test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents: 16030
diff changeset
45 %! f ();
26182
34617dd78f02 avoid possible leaked global variables in tests
John W. Eaton <jwe@octave.org>
parents: 25482
diff changeset
46 %! clear -global G; # cleanup after test
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
47
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
48 %!function f ()
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
49 %! global H = 1;
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
50 %!endfunction
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
51 %!test
17337
a31b54b5f84a Use only 1 space between '%!' and start of test/demo code.
Rik <rik@octave.org>
parents: 16937
diff changeset
52 %! f;
a31b54b5f84a Use only 1 space between '%!' and start of test/demo code.
Rik <rik@octave.org>
parents: 16937
diff changeset
53 %! fail ("H");
26182
34617dd78f02 avoid possible leaked global variables in tests
John W. Eaton <jwe@octave.org>
parents: 25482
diff changeset
54 %! clear -global H; # cleanup after test
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
55
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
56 %!function f ()
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
57 %! global H = 1;
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
58 %!endfunction
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
59 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
60 %!function g ()
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
61 %! fail ("H");
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
62 %!test
16213
b1283d4c06c2 test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents: 16030
diff changeset
63 %! g ();
26182
34617dd78f02 avoid possible leaked global variables in tests
John W. Eaton <jwe@octave.org>
parents: 25482
diff changeset
64 %! clear -global H; # cleanup after test
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
65
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
66 %!function f ()
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
67 %! global H = 1;
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
68 %!endfunction
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
69 %!function g ()
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
70 %! global H;
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
71 %! assert (H,1);
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
72 %!endfunction
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
73 %!test
16213
b1283d4c06c2 test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents: 16030
diff changeset
74 %! f ();
b1283d4c06c2 test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents: 16030
diff changeset
75 %! g ();
26182
34617dd78f02 avoid possible leaked global variables in tests
John W. Eaton <jwe@octave.org>
parents: 25482
diff changeset
76 %! clear -global H; # cleanup after test
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
77
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
78 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
79 %!function f ()
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
80 %! global H = 1;
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
81 %!endfunction
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
82 %!test
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
83 %! fail ("H");
26182
34617dd78f02 avoid possible leaked global variables in tests
John W. Eaton <jwe@octave.org>
parents: 25482
diff changeset
84 %! clear -global H; # cleanup after test
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
85
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
86 %!function f ()
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
87 %! global H = 1;
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
88 %!endfunction
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
89 %!function g ()
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
90 %! global H;
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
91 %! assert (H,1);
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
92 %!endfunction
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
93 %!test
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
94 %! f;
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
95 %! clear H;
5590
1ad66ea35fe5 [project @ 2006-01-06 00:24:05 by jwe]
jwe
parents:
diff changeset
96 %! g;
26182
34617dd78f02 avoid possible leaked global variables in tests
John W. Eaton <jwe@octave.org>
parents: 25482
diff changeset
97 %! clear -global H; # cleanup after test
25478
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
98
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
99 %!function r = f ()
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
100 %! x = 1;
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
101 %! global x;
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
102 %! r = x;
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
103 %!endfunction
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
104 %!test
25482
0d7a89bec20e improve warnings for global/local variable conflicts (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25478
diff changeset
105 %! warning ("off", "Octave:global-local-conflict", "local");
0d7a89bec20e improve warnings for global/local variable conflicts (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25478
diff changeset
106 %! clear global x ## clears global and local value
31564
332a6ccac881 maint: cleanup code in BIST tests to use Octave coding conventions.
Rik <rik@octave.org>
parents: 30564
diff changeset
107 %! global x;
25478
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
108 %! x = 0;
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
109 %! assert (f (), 0);
31564
332a6ccac881 maint: cleanup code in BIST tests to use Octave coding conventions.
Rik <rik@octave.org>
parents: 30564
diff changeset
110 %! global x;
25478
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
111 %! assert (x, 0);
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
112 %!test
25482
0d7a89bec20e improve warnings for global/local variable conflicts (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25478
diff changeset
113 %! warning ("off", "Octave:global-local-conflict", "local");
0d7a89bec20e improve warnings for global/local variable conflicts (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25478
diff changeset
114 %! clear global x ## clears global and local value
25478
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
115 %! assert (f (), 1);
31564
332a6ccac881 maint: cleanup code in BIST tests to use Octave coding conventions.
Rik <rik@octave.org>
parents: 30564
diff changeset
116 %! global x;
25478
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
117 %! assert (x, 1);
26182
34617dd78f02 avoid possible leaked global variables in tests
John W. Eaton <jwe@octave.org>
parents: 25482
diff changeset
118 %! clear -global x; # cleanup after test
25478
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
119
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
120 %!function r = f ()
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
121 %! x = 1;
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
122 %! global x = 3;
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
123 %! r = x;
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
124 %!endfunction
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
125 %!test
25482
0d7a89bec20e improve warnings for global/local variable conflicts (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25478
diff changeset
126 %! warning ("off", "Octave:global-local-conflict", "local");
0d7a89bec20e improve warnings for global/local variable conflicts (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25478
diff changeset
127 %! clear global x ## clears global and local value
31564
332a6ccac881 maint: cleanup code in BIST tests to use Octave coding conventions.
Rik <rik@octave.org>
parents: 30564
diff changeset
128 %! global x;
25478
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
129 %! x = 0;
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
130 %! assert (f (), 0);
31564
332a6ccac881 maint: cleanup code in BIST tests to use Octave coding conventions.
Rik <rik@octave.org>
parents: 30564
diff changeset
131 %! global x;
25478
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
132 %! assert (x, 0);
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
133 %!test
25482
0d7a89bec20e improve warnings for global/local variable conflicts (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25478
diff changeset
134 %! warning ("off", "Octave:global-local-conflict", "local");
25478
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
135 %! clear global x
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
136 %! assert (f (), 1);
31564
332a6ccac881 maint: cleanup code in BIST tests to use Octave coding conventions.
Rik <rik@octave.org>
parents: 30564
diff changeset
137 %! global x;
25478
a06983fe83a5 maybe preserve local value when declaring variable global (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
138 %! assert (x, 1);
26182
34617dd78f02 avoid possible leaked global variables in tests
John W. Eaton <jwe@octave.org>
parents: 25482
diff changeset
139 %! clear -global x; # cleanup after test
25482
0d7a89bec20e improve warnings for global/local variable conflicts (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25478
diff changeset
140
0d7a89bec20e improve warnings for global/local variable conflicts (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25478
diff changeset
141 %!test
0d7a89bec20e improve warnings for global/local variable conflicts (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25478
diff changeset
142 %! warning ("off", "Octave:global-local-conflict", "local");
0d7a89bec20e improve warnings for global/local variable conflicts (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25478
diff changeset
143 %! clear global x ## clears global and local value
0d7a89bec20e improve warnings for global/local variable conflicts (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25478
diff changeset
144 %! x = 42; ## local value
31564
332a6ccac881 maint: cleanup code in BIST tests to use Octave coding conventions.
Rik <rik@octave.org>
parents: 30564
diff changeset
145 %! global x; ## link to undefined global, global gets local value
25482
0d7a89bec20e improve warnings for global/local variable conflicts (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25478
diff changeset
146 %! assert (x, 42);
0d7a89bec20e improve warnings for global/local variable conflicts (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25478
diff changeset
147 %! clear x ## clears local; global still defined
0d7a89bec20e improve warnings for global/local variable conflicts (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25478
diff changeset
148 %! x = 13; ## new local value
0d7a89bec20e improve warnings for global/local variable conflicts (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25478
diff changeset
149 %! global x; ## link to existing global, local gets global value
0d7a89bec20e improve warnings for global/local variable conflicts (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25478
diff changeset
150 %! assert (x, 42);
0d7a89bec20e improve warnings for global/local variable conflicts (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25478
diff changeset
151 %! clear global x ## clears global and local value
0d7a89bec20e improve warnings for global/local variable conflicts (bug #54052)
John W. Eaton <jwe@octave.org>
parents: 25478
diff changeset
152 %! assert (exist ("x"), 0);
26182
34617dd78f02 avoid possible leaked global variables in tests
John W. Eaton <jwe@octave.org>
parents: 25482
diff changeset
153 %! clear -global x; # cleanup after test