zsh-workers
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <psprint@zdharma.org>
To: zsh-workers@zsh.org
Subject: Tests for substitutions
Date: Wed, 29 Mar 2017 09:04:18 +0200	[thread overview]
Message-ID: <etPan.58db5c72.3d1b58ba.17199@MacMini.local> (raw)

[-- Attachment #1: Type: text/plain, Size: 1766 bytes --]

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

[-- Attachment #2: D10subst.ztst.txt --]
[-- Type: text/plain, Size: 624 bytes --]

# 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

             reply	other threads:[~2017-03-29  7:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20170329072608epcas5p17078c2cac7402d90b44e23acb7d52946@epcas5p1.samsung.com>
2017-03-29  7:04 ` Sebastian Gniazdowski [this message]
2017-03-29  9:01   ` Peter Stephenson
     [not found] <etPan.58db5c72.2eb141f2.17199@MacMini.local>
2017-03-29  7:18 ` Sebastian Gniazdowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=etPan.58db5c72.3d1b58ba.17199@MacMini.local \
    --to=psprint@zdharma.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).