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

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

Bart Schaefer wrote on Sun, Feb 05, 2023 at 18:24:58 -0800:
> Forgot to mention in patch #1 email that I decided not to create a
> "nameref" built-in yet.
> Here are the test cases, I covered everything I could think of.  If
> you see something I missed, let me know.

> diff --git a/Test/K01nameref.ztst b/Test/K01nameref.ztst
> new file mode 100644
> index 000000000..b38831100
> --- /dev/null
> +++ b/Test/K01nameref.ztst

Add "K:" to Test/README?

> @@ -0,0 +1,439 @@
> +# Tests for the zsh/param/private module


> +%prep
> +
> + # Required in order to declare an unset hash for substitution test
> +
> + : ${ZTST_continue:=1}
> +
> +%test
> +
> + 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?

> + typeset -n ptr2='path[2]'
> + print -r -- $ptr2
> +0d:nameref to array element
> +>${path[2]}
> +

Did you mean "0q" rather than "0d"?

I guess we should make the test harness warn (at least) when the "d"
flag is present and expected stdout is not empty.

> +%clean

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.

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?


Haven't reviewed the V10private.ztst tests or the other two patches in
this series.



P.S.  I wonder if it'd be useful to write a scriptlet that takes
a one-liner in argv and emits on stdout a test that runs the one-liner and
expects its current exitcode/stdout/stderr.  The idea is to use it
along the lines of «Test/generate 'pwd' >> Test/B42pwd.ztst».

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