Mercurial > octave
annotate test/bug-54490.tst @ 25789:cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
* pt-eval.cc (tree_evaluator::visit_simple_assignment): Create lvalue
object before evaluating RHS of assignment expression.
* test/bug-54490.tst: New test.
* test/module.mk: Update.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 14 Aug 2018 15:25:21 -0400 |
parents | |
children | 2838bbd84b87 |
rev | line source |
---|---|
25789
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 %!function out = bug54490 () |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 %! global k; |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
3 %! k = 1; |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 %! out = 3; |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
5 %!endfunction |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
7 %!test |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
8 %! global k; |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
9 %! k = 2; |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
10 %! a = [5, 6]; |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 %! a(k) = bug54490 (); |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
12 %! assert (a, [5, 3]); |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
13 %! k = 2; |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
14 %! a = [5, 6]; |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
15 %! [a(k)] = bug54490 (); |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 %! assert (a, [5, 3]); |
cc9da21511c1
use consistent eval order in simple and multi assignment (bug #54490)
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 %! clear -global k; # cleanup after test |