Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH 2/3] Tests for named references



On Mon, Feb 6, 2023 at 4:36 PM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>
> Bart Schaefer wrote on Sun, Feb 05, 2023 at 18:24:58 -0800:
]> > +++ b/Test/K01nameref.ztst
>
> Add "K:" to Test/README?

Forgot that file even existed.  Added.

> > +# Tests for the zsh/param/private module
>
> Copy-pasto.

Fixed.

> > + typeset -n ptr=var
> > + typeset var=value
> > + unset ptr
> > + typeset -p var
> > +0:unset via nameref
> > +
>
> So this expects «typeset -p var» to return 0 and have no output.  Are
> these the correct expectations?

Matches ksh93 to the best of my ability to test.

>
> > + typeset -n ptr2='path[2]'
> > + print -r -- $ptr2
> > +0d:nameref to array element
> > +>${path[2]}
> > +
>
> Did you mean "0q" rather than "0d"?

Indeed I did.  Changed.

> How about tests for assigning to a nameref-to-hash?  (Entire hash, not
> hash element)  Or are these implied by the "assign to array" and "expand
> nameref-to-hash" tests.

I believe they are so implied.

> Also, in 1/3 you wrote "attempting to add an attribute to a named
> reference generates a warning", but I don't see a single test expecting
> a non-empty stderr?

Not sure what you mean here, there are lots of tests that expect a
zero exit status and check output only on stdout.  The fifth test
specifically attempts adding the "tag" attribute to a named reference
and looks for the expected warning.  In a number of cases I'm checking
that the state of variables has been restored to the expected state by
looking for both correct stdout of the earlier steps and "no such
variable" after the test is done, the intent being to catch any cases
where the nameref goes too far up the stack of scopes.

Consolidated patch for both proofreadings will follow if when there's
no futher discussion.




Messages sorted by: Reverse Date, Date, Thread, Author