zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: completion tests
@ 2000-03-01 11:44 Sven Wischnowsky
  2000-03-01 13:11 ` Tanaka Akira
  0 siblings, 1 reply; 8+ messages in thread
From: Sven Wischnowsky @ 2000-03-01 11:44 UTC (permalink / raw)
  To: zsh-workers


Tanaka Akira wrote:

> This is completion tests using zpty.

Wow!

> This is bit slow because this runs zsh for each test.  Probabily it
> should be rewritten to run only one zsh under pty to test.
> 
> Also, I couldn't extract display strings specified by compadd -d.  Is
> there a simple way to extract?

I'm not completely sure what you mean: a way to make those strings be
distinguishable in the output? I can't think of much either, maybe
something with list-colors, with a pattern like `* *', in the hope
that display strings normally contain a space while other matches
don't?


Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: PATCH: completion tests
  2000-03-01 11:44 PATCH: completion tests Sven Wischnowsky
@ 2000-03-01 13:11 ` Tanaka Akira
  0 siblings, 0 replies; 8+ messages in thread
From: Tanaka Akira @ 2000-03-01 13:11 UTC (permalink / raw)
  To: zsh-workers

In article <200003011144.MAA25867@beta.informatik.hu-berlin.de>,
  Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:

> > Also, I couldn't extract display strings specified by compadd -d.  Is
> > there a simple way to extract?
> 
> I'm not completely sure what you mean: a way to make those strings be
> distinguishable in the output? I can't think of much either, maybe
> something with list-colors, with a pattern like `* *', in the hope
> that display strings normally contain a space while other matches
> don't?

Spaces are not problem.  Actually comptest can handle filenames
containing spaces.

Z(2):akr@is27e1u11% touch 'A B' 'A  C'                              
Z(2):akr@is27e1u11% Src/zsh -f Test/comptest -D -z Src/zsh $'ls A\\ \t'
line: {ls A\ }{}
DESCRIPTION:{file}
FI:{A\ \ C}
FI:{A\ B}
Z(2):akr@is27e1u11% bin2ascii /tmp/comptest.debug     
l\bls A\\ <WIDGET><expand-or-complete>\r
<LBUFFER>ls A\\ </LBUFFER>\r
<RBUFFER></RBUFFER>\r
\x1B[H\x1B[2J\x1B[m\x1B[m\x1B[m\x1B[J<PROMPT>ls A\\\x1B[K\x1B[1C\r\r
<DESCRIPTION>file</DESCRIPTION>\x1B[K\r
\x1B[K\r
\x1B[J<LC><FI><RC>A\\ \\ C<EC>\r
<LC><TC><RC> <EC>\r
<LC><SP><RC>  <EC>\r
<LC><FI><RC>A\\ B<EC>\r
<LC><TC><RC> <EC>\r
<LC><SP><RC>  <EC>\r
\r
\x1B[m\x1B[m\x1B[m\x1B[J<PROMPT>ls A\\\x1B[K\x1B[1C<WIDGET><finish>\r

\EOF

It's because zsh delimits listed filenames by <LC><FI><RC> and <EC>.
Of course, this will be problem with filenames containing <EC> etc.
But it's not big problem because we can choose arbitrary long
delimiters.

The problem I wanted to mention in 9936 is that zsh doesn't delimit
display strings properly as:

Z(2):akr@is27e1u11% Src/zsh -f Test/comptest -D -z Src/zsh $'flex -\t' 
line: {flex -}{}
DESCRIPTION:{option}
NO:{-+ -- generate C++ scanner class}
NO:{--version}
Z(2):akr@is27e1u11% bin2ascii /tmp/comptest.debug|head                
f\bflex -<WIDGET><expand-or-complete>\r
<LBUFFER>flex -</LBUFFER>\r
<RBUFFER></RBUFFER>\r
\x1B[H\x1B[2J\x1B[m\x1B[m\x1B[m\x1B[J<PROMPT>flex -\x1B[K\r\r
<DESCRIPTION>option</DESCRIPTION>\x1B[K\r
\x1B[K\r
<LC><NO><RC>-+ -- generate C++ scanner class\x1B[K<EC>\r
\r
-7 -- generate 7-bit scanner\x1B[K<EC>\r
\r
Z(2):akr@is27e1u11% 

If `-7 -- generate 7-bit scanner' is delimited by <LC><NO><RC> and
<EC>, we can extract the string.  But there is no <LC><NO><RC> before
the string and `\e[K' is inserted before <EC>.

Following patch fixes comptest.

* It didn't work on NetBSD.
  (pty/tty buffer size problem?)

* Backslashes were unquoted by print.

* Debug option didn't work.

Index: Test/comptest
===================================================================
RCS file: /projects/zsh/zsh/Test/comptest,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 comptest
--- Test/comptest	2000/02/29 15:51:21	1.1.1.1
+++ Test/comptest	2000/03/01 13:00:21
@@ -20,14 +20,16 @@
 
 input="$*"
 
-init=\
-'stty columns 80 rows 24
+tmp=/tmp/comptest.$$
+
+cat <<End >$tmp
+stty columns 80 rows 24
 LISTMAX=10000000
-'"ZLS_COLORS='no=<NO>:fi=<FI>:di=<DI>:ln=<LN>:pi=<PI>:so=<SO>:bd=<BD>:cd=<CD>:ex=<EX>:mi=<MI>:tc=<TC>:sp=<SP>:lc=<LC>:ec=<EC>\n:rc=<RC>'
+ZLS_COLORS='no=<NO>:fi=<FI>:di=<DI>:ln=<LN>:pi=<PI>:so=<SO>:bd=<BD>:cd=<CD>:ex=<EX>:mi=<MI>:tc=<TC>:sp=<SP>:lc=<LC>:ec=<EC>\n:rc=<RC>'
 bindkey -e
 autoload -U compinit
 compinit $dump
-"'zstyle ":completion:*" group-name ""
+zstyle ":completion:*" group-name ""
 zstyle ":completion*:messages" format "<MESSAGE>%d</MESSAGE>
 "
 zstyle ":completion*:descriptions" format "<DESCRIPTION>%d</DESCRIPTION>
@@ -39,7 +41,7 @@
 expand-or-complete-with-report () {
   print -lr "<WIDGET><expand-or-complete>"
   zle expand-or-complete
-  print -lr - "<LBUFFER>$LBUFFER</LBUFFER>" "<RBUFFER>$RBUFFER</RBUFFER>"
+  print -lr - "<LBUFFER>\$LBUFFER</LBUFFER>" "<RBUFFER>\$RBUFFER</RBUFFER>"
   zle clear-screen
   zle -R
 }
@@ -59,19 +61,25 @@
 bindkey "^I" expand-or-complete-with-report
 bindkey "^D" list-choices-with-report
 bindkey "^Z" finish
-'"$code"
+$code
+End
 
 export PS1="<PROMPT>"
 zpty zsh "$zsh" -f
 
 zpty -r zsh log "*<PROMPT>*"
 
-zpty -w zsh "eval ${init:q}"
+zpty -w zsh ". $tmp"
 zpty -r zsh log "*<PROMPT>*"
+rm $tmp
 
 zpty -w zsh "$input"$'\C-Z'
 zpty -r zsh log "*<WIDGET><finish>*"
 
+if [[ -n "$debug" ]]; then
+  print -lr - "$log" > /tmp/comptest.debug
+fi
+
 logs=(${(s:<WIDGET>:)log})
 shift logs
 
@@ -83,12 +91,12 @@
     log="${log[$mend[1]+1,-1]}"
     if (( 0 <= $mbegin[2] )); then
       if [[ $match[2] != TC && $match[3] != \ # ]]; then
-	print "$match[2]:{$match[3]}"
+	print -lr "$match[2]:{$match[3]}"
       fi
     elif (( 0 <= $mbegin[4] )); then
-      print "DESCRIPTION:{$match[4]}"
+      print -lr "DESCRIPTION:{$match[4]}"
     elif (( 0 <= $mbegin[5] )); then
-      print "MESSAGE:{$match[5]}"
+      print -lr "MESSAGE:{$match[5]}"
     fi
   done
 done
-- 
Tanaka Akira


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: PATCH: completion tests
  2000-03-01 14:01 Sven Wischnowsky
  2000-03-01 14:52 ` Tanaka Akira
@ 2000-03-01 17:13 ` Tanaka Akira
  1 sibling, 0 replies; 8+ messages in thread
From: Tanaka Akira @ 2000-03-01 17:13 UTC (permalink / raw)
  To: zsh-workers

In article <200003011401.PAA27932@beta.informatik.hu-berlin.de>,
  Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:

> I couldn't test it with comptest, though, because that doesn't seem to 
> work for me, dunno where the problem is.

I found a timing problem in comptest.  The problem is reproducible on
Vine Linux --- Redhat based distribution mainly distributed in Japan.

When a child process on pty exits just after printing a string, zsh
may overlook the string.

This patch avoids the problem by sleeping a second before exit.

Index: Test/comptest
===================================================================
RCS file: /projects/zsh/zsh/Test/comptest,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 comptest
--- Test/comptest	2000/03/01 15:38:26	1.1.1.3
+++ Test/comptest	2000/03/01 17:05:26
@@ -54,6 +54,7 @@
 }
 finish () {
   print "<WIDGET><finish>"
+  sleep 1
   exit 0
 }
 zle -N expand-or-complete-with-report
@@ -68,14 +69,23 @@
 export PS1="<PROMPT>"
 zpty zsh "$zsh" -f
 
-zpty -r zsh log "*<PROMPT>*"
+zpty -r zsh log1 "*<PROMPT>*" || { 
+  print first prompt doesn\'t appered.
+  exit 1
+}
 
 zpty -w zsh ". $tmp"
-zpty -r zsh log "*<PROMPT>*"
+zpty -r zsh log2 "*<PROMPT>*" || {
+  print second prompt doesn\'t appered.
+  exit 1
+}
 rm $tmp
 
-zpty -w zsh "$input"$'\C-Z'
-zpty -r zsh log "*<WIDGET><finish>*"
+zpty -n -w zsh "$input"$'\C-Z'
+zpty -r zsh log "*<WIDGET><finish>*" || {
+  print finish widget doesn\'t invoked.
+  exit 1
+}
 
 if [[ -n "$debug" ]]; then
   print -lr - "$log" > /tmp/comptest.debug
Index: Test/53completion.ztst
===================================================================
RCS file: /projects/zsh/zsh/Test/53completion.ztst,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 53completion.ztst
--- Test/53completion.ztst	2000/02/29 15:51:21	1.1.1.1
+++ Test/53completion.ztst	2000/03/01 17:05:35
@@ -104,11 +104,11 @@
 >DESCRIPTION:{desc1}
 >NO:{arg1}
 
-# code='compdef _tst tst; _tst () { _arguments "-\+[opt]" }'
-# comptest -c "$code" $'tst -\C-D'
-#0:_arguments
-#>DESCRIPTION:{option}
-#>NO:{-+ -- opt}
+ code='compdef _tst tst; _tst () { _arguments "-\+[opt]" }'
+ comptest -c "$code" $'tst -\C-D'
+0:_arguments
+>DESCRIPTION:{option}
+>NO:{-+ -- opt}
 
  code='compdef _tst tst; _tst () { _arguments "1:desc1:(arg1)" }'
  comptest -c "$code" $'tst \t'
-- 
Tanaka Akira


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: PATCH: completion tests
  2000-03-01 15:28 Sven Wischnowsky
@ 2000-03-01 15:37 ` Tanaka Akira
  0 siblings, 0 replies; 8+ messages in thread
From: Tanaka Akira @ 2000-03-01 15:37 UTC (permalink / raw)
  To: zsh-workers

In article <200003011528.QAA28206@beta.informatik.hu-berlin.de>,
  Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:

> Ah, I forgot to say: this is intentional. It comes from the printfmt() 
> functions to ensure that printing a completion list over a completion
> list doesn't flicker. No way around that.

Ok.  I modified comptest to remove it.

Index: Test/.distfiles
===================================================================
RCS file: /projects/zsh/zsh/Test/.distfiles,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 .distfiles
--- Test/.distfiles	2000/02/20 01:27:22	1.1.1.7
+++ Test/.distfiles	2000/03/01 15:34:31
@@ -1,7 +1,7 @@
 DISTFILES_SRC='
     .cvsignore .distfiles Makefile.in
-    ztst.zsh
+    ztst.zsh comptest
     01grammar.ztst 02alias.ztst 03quoting.ztst 04redirect.ztst
     05command.ztst 06arith.ztst 07cond.ztst 08traps.ztst 09funcdef.ztst
-    10prompt.ztst 50cd.ztst 51xtrace.ztst
+    10prompt.ztst 50cd.ztst 51xtrace.ztst 52zregexparse.ztst 53completion.ztst
 '
Index: Test/comptest
===================================================================
RCS file: /projects/zsh/zsh/Test/comptest,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 comptest
--- Test/comptest	2000/03/01 13:14:50	1.1.1.2
+++ Test/comptest	2000/03/01 15:34:31
@@ -7,6 +7,7 @@
 dump=(-D)
 code=
 zsh=${ZSH:-zsh}
+termcap_ce="$(echotc ce)"
 
 while getopts Dd:c:z: opt; do
   case $opt in
@@ -91,7 +92,7 @@
     log="${log[$mend[1]+1,-1]}"
     if (( 0 <= $mbegin[2] )); then
       if [[ $match[2] != TC && $match[3] != \ # ]]; then
-	print -lr "$match[2]:{$match[3]}"
+	print -lr "$match[2]:{${match[3]%$termcap_ce}}"
       fi
     elif (( 0 <= $mbegin[4] )); then
       print -lr "DESCRIPTION:{$match[4]}"
-- 
Tanaka Akira


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: PATCH: completion tests
@ 2000-03-01 15:28 Sven Wischnowsky
  2000-03-01 15:37 ` Tanaka Akira
  0 siblings, 1 reply; 8+ messages in thread
From: Sven Wischnowsky @ 2000-03-01 15:28 UTC (permalink / raw)
  To: zsh-workers


Tanaka Akira wrote:

> But, `\x1B[K' --- el (clear to end of line) terminfo entry --- is
> printed before ec-code.

Ah, I forgot to say: this is intentional. It comes from the printfmt() 
functions to ensure that printing a completion list over a completion
list doesn't flicker. No way around that.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: PATCH: completion tests
  2000-03-01 14:01 Sven Wischnowsky
@ 2000-03-01 14:52 ` Tanaka Akira
  2000-03-01 17:13 ` Tanaka Akira
  1 sibling, 0 replies; 8+ messages in thread
From: Tanaka Akira @ 2000-03-01 14:52 UTC (permalink / raw)
  To: zsh-workers

In article <200003011401.PAA27932@beta.informatik.hu-berlin.de>,
  Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:

> The problem was that the ec-code was output differently and for all
> other codes there was the optimisation to not print them again when we 
> already printed them and no other code since then.
> 
> The patch below should force the lc/no/rc codes to be printed again
> after we printed ec. In terms of optimisation, this is a bit unlucky,
> but since ec may contain anything, it was indeed wrong before.

Thanks.  Now comptest works better with display strings.

Z(2):akr@is27e1u11% Src/zsh -f Test/comptest -D -z Src/zsh $'flex -\t'|bin2ascii|head
line: {flex -}{}
DESCRIPTION:{option}
NO:{-+ -- generate C++ scanner class\x1B[K}
NO:{-7 -- generate 7-bit scanner\x1B[K}
NO:{-8 -- generate 8-bit scanner\x1B[K}
NO:{-B -- generate batch scanner\x1B[K}
NO:{-C -- specify degree of table compression\x1B[K}
NO:{-F -- use fast scanner table representation\x1B[K}
NO:{-I -- generate interactive scanner\x1B[K}
NO:{-L -- don't generate #line directives\x1B[K}
Z(2):akr@is27e1u11% bin2ascii /tmp/comptest.debug|head
f\bflex -<WIDGET><expand-or-complete>\r
<LBUFFER>flex -</LBUFFER>\r
<RBUFFER></RBUFFER>\r
\x1B[H\x1B[2J\x1B[m\x1B[m\x1B[m\x1B[J<PROMPT>flex -\x1B[K\r\r
<DESCRIPTION>option</DESCRIPTION>\x1B[K\r
\x1B[K\r
<LC><NO><RC>-+ -- generate C++ scanner class\x1B[K<EC>\r
\r
<LC><NO><RC>-7 -- generate 7-bit scanner\x1B[K<EC>\r
\r
Z(2):akr@is27e1u11% 

But, `\x1B[K' --- el (clear to end of line) terminfo entry --- is
printed before ec-code.
-- 
Tanaka Akira


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: PATCH: completion tests
@ 2000-03-01 14:01 Sven Wischnowsky
  2000-03-01 14:52 ` Tanaka Akira
  2000-03-01 17:13 ` Tanaka Akira
  0 siblings, 2 replies; 8+ messages in thread
From: Sven Wischnowsky @ 2000-03-01 14:01 UTC (permalink / raw)
  To: zsh-workers


Tanaka Akira wrote:

> ...
> 
> The problem I wanted to mention in 9936 is that zsh doesn't delimit
> display strings properly as:

I wasn't aware of the unbalanced codes for display strings, but I
understood you all right. My suggestion was to force display strings
to be delimited by using a list-colors pattern and to make that
pattern match only display strings by testing if the string contains a 
space -- which display strings normally do and for other normal match
strings we could probably avoid it in completion tests.

However...

> Z(2):akr@is27e1u11% Src/zsh -f Test/comptest -D -z Src/zsh $'flex -\t' 
> line: {flex -}{}
> DESCRIPTION:{option}
> NO:{-+ -- generate C++ scanner class}
> NO:{--version}
> Z(2):akr@is27e1u11% bin2ascii /tmp/comptest.debug|head                
> f\bflex -<WIDGET><expand-or-complete>\r
> <LBUFFER>flex -</LBUFFER>\r
> <RBUFFER></RBUFFER>\r
> \x1B[H\x1B[2J\x1B[m\x1B[m\x1B[m\x1B[J<PROMPT>flex -\x1B[K\r\r
> <DESCRIPTION>option</DESCRIPTION>\x1B[K\r
> \x1B[K\r
> <LC><NO><RC>-+ -- generate C++ scanner class\x1B[K<EC>\r
> \r
> -7 -- generate 7-bit scanner\x1B[K<EC>\r
> \r
> Z(2):akr@is27e1u11% 
> 
> If `-7 -- generate 7-bit scanner' is delimited by <LC><NO><RC> and
> <EC>, we can extract the string.  But there is no <LC><NO><RC> before
> the string and `\e[K' is inserted before <EC>.

The problem was that the ec-code was output differently and for all
other codes there was the optimisation to not print them again when we 
already printed them and no other code since then.

The patch below should force the lc/no/rc codes to be printed again
after we printed ec. In terms of optimisation, this is a bit unlucky,
but since ec may contain anything, it was indeed wrong before.

I couldn't test it with comptest, though, because that doesn't seem to 
work for me, dunno where the problem is.

Bye
 Sven

diff -ru ../z.old/Src/Zle/complist.c Src/Zle/complist.c
--- ../z.old/Src/Zle/complist.c	Wed Mar  1 11:37:44 2000
+++ Src/Zle/complist.c	Wed Mar  1 14:34:43 2000
@@ -403,7 +403,7 @@
 static void
 zlrputs(Listcols c, char *cap)
 {
-    if (strcmp(last_cap, cap)) {
+    if (!*last_cap || strcmp(last_cap, cap)) {
 	VARARR(char, buf, lr_caplen + max_caplen + 1);
 
 	strcpy(buf, c->files[COL_LC]->col);
@@ -435,9 +435,10 @@
 static void
 zcoff(void)
 {
-    if (mcolors.files[COL_EC] && mcolors.files[COL_EC]->col)
+    if (mcolors.files[COL_EC] && mcolors.files[COL_EC]->col) {
 	tputs(mcolors.files[COL_EC]->col, 1, putshout);
-    else
+	*last_cap = '\0';
+    } else
 	zcputs(&mcolors, NULL, COL_NO);
 }
 

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 8+ messages in thread

* PATCH: completion tests
@ 2000-02-29 15:50 Tanaka Akira
  0 siblings, 0 replies; 8+ messages in thread
From: Tanaka Akira @ 2000-02-29 15:50 UTC (permalink / raw)
  To: zsh-workers

This is completion tests using zpty.

This is bit slow because this runs zsh for each test.  Probabily it
should be rewritten to run only one zsh under pty to test.

Also, I couldn't extract display strings specified by compadd -d.  Is
there a simple way to extract?

Of course, it should have more tests.

Index: Src/Zle/complist.c
===================================================================
RCS file: /projects/zsh/zsh/Src/Zle/complist.c,v
retrieving revision 1.1.1.42
diff -u -r1.1.1.42 complist.c
--- Src/Zle/complist.c	2000/02/23 15:18:49	1.1.1.42
+++ Src/Zle/complist.c	2000/02/29 15:33:59
@@ -745,7 +745,7 @@
 	}
 	zcoff();
 	if (!lastc) {
-	    zcputs(&mcolors, g->name, COL_NO);
+	    zcputs(&mcolors, g->name, COL_SP);
 	    fputs("  ", shout);
 	    zcoff();
 	}
--- /dev/null	Wed Mar  1 00:32:29 2000
+++ Test/comptest	Wed Mar  1 00:47:02 2000
@@ -0,0 +1,94 @@
+#!/usr/local/bin/zsh -f
+
+zmodload zsh/zpty
+setopt extendedglob
+
+debug=
+dump=(-D)
+code=
+zsh=${ZSH:-zsh}
+
+while getopts Dd:c:z: opt; do
+  case $opt in
+    D) debug=yes;;
+    d) dump=(-d "$OPTARG");;
+    c) code="$OPTARG";;
+    z) zsh="$OPTARG";;
+  esac
+done
+(( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
+
+input="$*"
+
+init=\
+'stty columns 80 rows 24
+LISTMAX=10000000
+'"ZLS_COLORS='no=<NO>:fi=<FI>:di=<DI>:ln=<LN>:pi=<PI>:so=<SO>:bd=<BD>:cd=<CD>:ex=<EX>:mi=<MI>:tc=<TC>:sp=<SP>:lc=<LC>:ec=<EC>\n:rc=<RC>'
+bindkey -e
+autoload -U compinit
+compinit $dump
+"'zstyle ":completion:*" group-name ""
+zstyle ":completion*:messages" format "<MESSAGE>%d</MESSAGE>
+"
+zstyle ":completion*:descriptions" format "<DESCRIPTION>%d</DESCRIPTION>
+"
+zstyle ":completion*:options" verbose yes
+zstyle ":completion*:values" verbose yes
+setopt noalwayslastprompt listrowsfirst completeinword
+zmodload zsh/complist
+expand-or-complete-with-report () {
+  print -lr "<WIDGET><expand-or-complete>"
+  zle expand-or-complete
+  print -lr - "<LBUFFER>$LBUFFER</LBUFFER>" "<RBUFFER>$RBUFFER</RBUFFER>"
+  zle clear-screen
+  zle -R
+}
+list-choices-with-report () {
+  print -lr "<WIDGET><list-choices>"
+  zle list-choices
+  zle clear-screen
+  zle -R
+}
+finish () {
+  print "<WIDGET><finish>"
+  exit 0
+}
+zle -N expand-or-complete-with-report
+zle -N list-choices-with-report
+zle -N finish
+bindkey "^I" expand-or-complete-with-report
+bindkey "^D" list-choices-with-report
+bindkey "^Z" finish
+'"$code"
+
+export PS1="<PROMPT>"
+zpty zsh "$zsh" -f
+
+zpty -r zsh log "*<PROMPT>*"
+
+zpty -w zsh "eval ${init:q}"
+zpty -r zsh log "*<PROMPT>*"
+
+zpty -w zsh "$input"$'\C-Z'
+zpty -r zsh log "*<WIDGET><finish>*"
+
+logs=(${(s:<WIDGET>:)log})
+shift logs
+
+for log in "$logs[@]"; do
+  if [[ "$log" = (#b)*$'<LBUFFER>'(*)$'</LBUFFER>\r\n<RBUFFER>'(*)$'</RBUFFER>'* ]]; then
+    print -lr "line: {$match[1]}{$match[2]}"
+  fi
+  while (( ${(N)log#*(#b)(<LC><(??)><RC>(*)<EC>|<DESCRIPTION>(*)</DESCRIPTION>|<MESSAGE>(*)</MESSAGE>)} )); do
+    log="${log[$mend[1]+1,-1]}"
+    if (( 0 <= $mbegin[2] )); then
+      if [[ $match[2] != TC && $match[3] != \ # ]]; then
+	print "$match[2]:{$match[3]}"
+      fi
+    elif (( 0 <= $mbegin[4] )); then
+      print "DESCRIPTION:{$match[4]}"
+    elif (( 0 <= $mbegin[5] )); then
+      print "MESSAGE:{$match[5]}"
+    fi
+  done
+done
--- /dev/null	Wed Mar  1 00:32:29 2000
+++ Test/53completion.ztst	Wed Mar  1 00:47:18 2000
@@ -0,0 +1,136 @@
+# Tests for completion system.
+
+%prep
+
+  comptest () { $ZTST_testdir/../Src/zsh -f $ZTST_srcdir/comptest -z $ZTST_testdir/../Src/zsh -d $ZTST_testdir/compdump.tmp "$@" }
+
+  mkdir comp.tmp
+  cd comp.tmp
+
+  mkdir dir1
+  mkdir dir2
+  touch file1
+  touch file2
+
+%test
+
+  comptest $': \t\t\t\t\t\t\t'
+0:directories and files
+>line: {: }{}
+>DESCRIPTION:{file}
+>DI:{dir1}
+>DI:{dir2}
+>FI:{file1}
+>FI:{file2}
+>line: {: dir1/}{}
+>line: {: dir2/}{}
+>line: {: file1}{}
+>line: {: file2}{}
+>line: {: dir1/}{}
+>line: {: dir2/}{}
+
+  comptest -c '_users () { compadd user1 user2 }' $': ~\t\t\t\t\t'
+0:tilde
+>line: {: ~user}{}
+>line: {: ~user}{}
+>NO:{user1}
+>NO:{user2}
+>line: {: ~user1}{}
+>line: {: ~user2}{}
+>line: {: ~user1}{}
+
+ code='compdef _tst tst; _tst () { _arguments ":desc1:(arg1)" }'
+ comptest -c "$code" $'tst \t'
+0:_arguments
+>line: {tst arg1 }{}
+
+ comptest -c "$code" $'tst a\t'
+0:_arguments
+>line: {tst arg1 }{}
+
+ comptest -c "$code" $'tst ar\t'
+0:_arguments
+>line: {tst arg1 }{}
+
+ comptest -c "$code" $'tst arg\t'
+0:_arguments
+>line: {tst arg1 }{}
+
+ comptest -c "$code" $'tst arg1\t'
+0:_arguments
+>line: {tst arg1 }{}
+
+ comptest -c "$code" $'tst r\t'
+0:_arguments
+>line: {tst r}{}
+
+ comptest -c "$code" $'tst x\t'
+0:_arguments
+>line: {tst x}{}
+
+ comptest -c "$code" $'tst a \t'
+0:_arguments
+>line: {tst a }{}
+>MESSAGE:{no more arguments}
+
+ comptest -c "$code" $'tst a b \t'
+0:_arguments
+>line: {tst a b }{}
+>MESSAGE:{no more arguments}
+
+ code='compdef _tst tst; _tst () { _arguments ":desc1:(a b)" }'
+ comptest -c "$code" $'tst \t'
+0:_arguments
+>line: {tst }{}
+>DESCRIPTION:{desc1}
+>NO:{a}
+>NO:{b}
+
+ code='compdef _tst tst; _tst () { _arguments ":desc1:(arg1)" ":desc2:(arg2)" ":desc3:(arg3)" }'
+ comptest -c "$code" $'tst \t'
+0:_arguments
+>line: {tst arg1 }{}
+
+ comptest -c "$code" $'tst arg1 \t'
+0:_arguments
+>line: {tst arg1 arg2 }{}
+
+ comptest -c "$code" $'tst arg1 arg2 \t'
+0:_arguments
+>line: {tst arg1 arg2 arg3 }{}
+
+ comptest -c "$code" $'tst \C-D'
+0:_arguments
+>DESCRIPTION:{desc1}
+>NO:{arg1}
+
+# code='compdef _tst tst; _tst () { _arguments "-\+[opt]" }'
+# comptest -c "$code" $'tst -\C-D'
+#0:_arguments
+#>DESCRIPTION:{option}
+#>NO:{-+ -- opt}
+
+ code='compdef _tst tst; _tst () { _arguments "1:desc1:(arg1)" }'
+ comptest -c "$code" $'tst \t'
+0:_arguments
+>line: {tst arg1 }{}
+
+ code='compdef _tst tst; _tst () { _arguments "-x" ":arg:" }'
+ comptest -c "$code" $'tst -\t'
+0:_arguments
+>line: {tst -x }{}
+
+ code='compdef _tst tst; _tst () { _arguments "-x:arg:" }'
+ comptest -c "$code" $'tst -x\t'
+0:_arguments
+>line: {tst -x }{}
+
+ code='
+   compdef _tst tst
+   _tst () { _arguments "-a" "*::rest:_tst2" }
+   _tst2 () { compadd - -b }
+ '
+ comptest -c "$code" $'tst arg -\t'
+0:_arguments
+>line: {tst arg -b }{}
+
-- 
Tanaka Akira


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2000-03-01 17:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-03-01 11:44 PATCH: completion tests Sven Wischnowsky
2000-03-01 13:11 ` Tanaka Akira
  -- strict thread matches above, loose matches on Subject: below --
2000-03-01 15:28 Sven Wischnowsky
2000-03-01 15:37 ` Tanaka Akira
2000-03-01 14:01 Sven Wischnowsky
2000-03-01 14:52 ` Tanaka Akira
2000-03-01 17:13 ` Tanaka Akira
2000-02-29 15:50 Tanaka Akira

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).