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

Tests for substitutions



Hello,
I'm little anxious about future of ZUI, despite that it works from Zsh-4.3.17 to 5.3.1-dev.0, because it uses very much power that Zsh has. In e.g. Python it wouldn't be possible to do what follows:

- create hyperlink text with 3 backend variables, that is turned into Unicode text – with 1 substitution

The substitution uses P,Q,A,s,r,m flags. I've created a test for it. Hyperlink is created as follows:

 my_width=6
 my_index=1
 my_options=Option1      
 hyperlink=$'\034'"MYID"$'\034'"DATA1"$'\034'"DATA2"$'\034'"DATA3"$'\034'"my_width"$'\034'"my_index"$'\034'"my_options"$'\02'

The substitution is:

array=( "${array[@]//(#b).../${(mr:${(P)${(Q)match[1]}}:: :)${(As:;:)${(P)${(Q)match[3]}}}[${(P)${(Q)match[2]}}]}}" )

I've skipped the part that matches the three embedded parameters. So, all is unicode-display-width padded and trimmed to ${(P)match[1]}, my_options ${(P)match[3]} is splitted on ';', (A) makes (s) return array also for no-split-case, and this is indexed with ${(P)match[2]} – with my_index value.

Could this test be added? Because besides this, there are also no tests for substitutions. The test stresses P,Q,A,s,r,m and code execution with (#b), but I would also add some few tests for zipping, :|, :*, etc. Not that I aim at saturating substitution topic, just would ship few tests.

However, while the code works in shell, testing framework outputs:
(eval):6: unrecognized modifier `T'
(eval):6: bad math expression: empty string

the "bad math …" usually comes from wrong backend parameter name in hyperlink, but the code works fine in shell. Could someone look into testing framework? It apparently does something with test's text.

--
Sebastian Gniazdowski
psprint /at/ zdharma.org
# Tests for substitution

%prep

%test

  my_width=6
  my_index=1
  my_options=Option1
  hyperlink=$'\034'"MYID"$'\034'"DATA1"$'\034'"DATA2"$'\034'"DATA3"$'\034'"my_width"$'\034'"my_index"$'\034'"my_options"$'\02'
  array=( $hyperlink "Regular text" $hyperlink )
  array=( "${array[@]//(#b)$'\034'[^$'\034']#$'\034'[^$'\034']#$'\034'[^$'\034']#$'\034'[^$'\034']#$'\034'([^$'\034']#)$'\034'([^$'\034']#)$'\034'([^$'\02']#)$'\02'/${(mr:${(P)${(Q)match[1]}}:: :)${(As:;:)${(P)${(Q)match[3]}}}[${(P)${(Q)match[2]}}]}}" )
  print -rl -- "${array[@]}"
0:Test substitution that uses P,Q,A,s,r,m flags
>Option
>Regular text
>Option


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