Mailingliste - Einträge 2005

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [qftestJUI] Assigning procedure result into the variable that is used in parameter

  • Subject: Re: [qftestJUI] Assigning procedure result into the variable that is used in parameter
  • From: Gregor Schmid <Gregor.Schmid@?.de>
  • Date: Thu, 19 May 2005 08:22:28 -0000

Hi Yuri,

you're becoming an expert on qftestJUI variables... :-)

That's a tricky situation you've uncovered and the explanation is
complex. When binding a local variable, "var" in this case, qftestJUI
looks for a set of bindings on the current call stack (think "tests
and sequences") in which that variable is bound and overrides that

When you execute the whole test, you've got such a variable binding in
the test node and everything is fine. When you execute just the
"mytestFAIL" sequence, the binding for "var" in the test node isn't
taken into account.

Now, when there is no previous binding for a local variable, there are
two possibilities:

- When running inside a Procedure, the variable is bound at the
  innermost current Procedure level

- Otherwise, the variable is bound at the innermost level available
  and becomes very short-lived.

Your mytestFAIL example is of the second type. To complicate things
even more, the parameters of the procedure call act as a set of
variable bindings and that's where the binding for "var" ends up, so it
goes out of scope immediately again with the end of the procedure
call. That may be considered a bug and we'll take care of that.

Nevertheless, as a general rule, if you are using local variables it
is a good idea to have a binding for the variable somewhere that tells
qftestJUI about the intended scope for the variable. This is similar
to declaring the variable in a programming languages like Java or C.

I hope that shed some light :-)

Best regards,

"Yuri Tsyganenko" <tsyg@?.com> writes:

> Hi all,
> I tried some simple tests to understand what's happening when procedure
> returns a result. The snag is that the same variable is used in
> parameter and in assigning result.
>  To see the strange result execute:
> 1) the whole test - Works OK
> 2) Just the mytestFAIL sequence - Fails: the result is not assigned into
> 'var'
> 3) mytestOK sequence - it is just to show how to overcome the problem
>    Adding local variable 'var' into 'mytestFAIL' sequence changes the
> result of procedure execution: the result becomes equal to those
> returned by procedure.
> 	Otherwise, without that local variable, but when 'var' is
> assigned in outer test: executing just 'mytestFAIL' sequence will leave
> 'var' equal to the very initial value, as if the procedure was not
> called.
>  Why is this difference?
> Yuri Tsyganenko
> tsyg@?.com

Gregor Schmid                                Gregor.Schmid@?.de
Quality First Software GmbH           
Tulpenstr. 41                                Tel: +49 8171 919870
DE-82538 Geretsried                          Fax: +49 8171 919876