Mercurial > octave
comparison test/global.tst @ 31564:332a6ccac881 stable
maint: cleanup code in BIST tests to use Octave coding conventions.
* data.cc: Use keyword "endfor" rather than bare "end".
* file-io.cc, graphics.cc:
Remove semicolon ';' at end of "end_try_catch" keyword.
* variables.cc, bug-35448.tst, bug-53027.tst, bug-53579.tst, bug-53599.tst,
bug-53956.tst, bug-55758.tst, global.tst:
Use semicolon ';' after "global" variable declaration.
* for.tst, io.tst: Delete semicolon ';' at end of "for" loop declaration.
* struct.tst: Delete semicolon ';' at end of "function" declaration.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 27 Nov 2022 17:01:00 -0800 |
parents | 796f54d4ddbf |
children | 597f3ee61a48 |
comparison
equal
deleted
inserted
replaced
31562:8029e9b88950 | 31564:332a6ccac881 |
---|---|
102 %! r = x; | 102 %! r = x; |
103 %!endfunction | 103 %!endfunction |
104 %!test | 104 %!test |
105 %! warning ("off", "Octave:global-local-conflict", "local"); | 105 %! warning ("off", "Octave:global-local-conflict", "local"); |
106 %! clear global x ## clears global and local value | 106 %! clear global x ## clears global and local value |
107 %! global x | 107 %! global x; |
108 %! x = 0; | 108 %! x = 0; |
109 %! assert (f (), 0); | 109 %! assert (f (), 0); |
110 %! global x | 110 %! global x; |
111 %! assert (x, 0); | 111 %! assert (x, 0); |
112 %!test | 112 %!test |
113 %! warning ("off", "Octave:global-local-conflict", "local"); | 113 %! warning ("off", "Octave:global-local-conflict", "local"); |
114 %! clear global x ## clears global and local value | 114 %! clear global x ## clears global and local value |
115 %! assert (f (), 1); | 115 %! assert (f (), 1); |
116 %! global x | 116 %! global x; |
117 %! assert (x, 1); | 117 %! assert (x, 1); |
118 %! clear -global x; # cleanup after test | 118 %! clear -global x; # cleanup after test |
119 | 119 |
120 %!function r = f () | 120 %!function r = f () |
121 %! x = 1; | 121 %! x = 1; |
123 %! r = x; | 123 %! r = x; |
124 %!endfunction | 124 %!endfunction |
125 %!test | 125 %!test |
126 %! warning ("off", "Octave:global-local-conflict", "local"); | 126 %! warning ("off", "Octave:global-local-conflict", "local"); |
127 %! clear global x ## clears global and local value | 127 %! clear global x ## clears global and local value |
128 %! global x | 128 %! global x; |
129 %! x = 0; | 129 %! x = 0; |
130 %! assert (f (), 0); | 130 %! assert (f (), 0); |
131 %! global x | 131 %! global x; |
132 %! assert (x, 0); | 132 %! assert (x, 0); |
133 %!test | 133 %!test |
134 %! warning ("off", "Octave:global-local-conflict", "local"); | 134 %! warning ("off", "Octave:global-local-conflict", "local"); |
135 %! clear global x | 135 %! clear global x |
136 %! assert (f (), 1); | 136 %! assert (f (), 1); |
137 %! global x | 137 %! global x; |
138 %! assert (x, 1); | 138 %! assert (x, 1); |
139 %! clear -global x; # cleanup after test | 139 %! clear -global x; # cleanup after test |
140 | 140 |
141 %!test | 141 %!test |
142 %! warning ("off", "Octave:global-local-conflict", "local"); | 142 %! warning ("off", "Octave:global-local-conflict", "local"); |
143 %! clear global x ## clears global and local value | 143 %! clear global x ## clears global and local value |
144 %! x = 42; ## local value | 144 %! x = 42; ## local value |
145 %! global x ## link to undefined global, global gets local value | 145 %! global x; ## link to undefined global, global gets local value |
146 %! assert (x, 42); | 146 %! assert (x, 42); |
147 %! clear x ## clears local; global still defined | 147 %! clear x ## clears local; global still defined |
148 %! x = 13; ## new local value | 148 %! x = 13; ## new local value |
149 %! global x; ## link to existing global, local gets global value | 149 %! global x; ## link to existing global, local gets global value |
150 %! assert (x, 42); | 150 %! assert (x, 42); |