zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: Completion matching control test. (Try 2)
@ 2000-05-17 11:57 Sven Wischnowsky
  0 siblings, 0 replies; 9+ messages in thread
From: Sven Wischnowsky @ 2000-05-17 11:57 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> ...
> 
> The failure included below looks like a bug in the matcher code, because
> the L spec should cause the string on the line to be retained.  Several
> more tests fail for the same reason (I commented out the cleanup/exit in
> ZTST_testfailed to force it to run them all).

Right, caused by 11364. Sorry.

> I suspect the other failed tests are confusion over `*' vs. `**' in the
> matcher patterns, but I'm not sure.  For example, the test
> 
> Documentation example using "r:|[A-Z0-9]=* r:|=*", input H
> 
> works if I change the * to **, and the "input 2" test after it also gives
> the right output with ** but fails based on the ending cursor position.
> 
> (Does that mean the examples in the doc are out of date?  I haven't looked
> yet.)

Yes, they were, due to the fixed `*'s-don't-match-the-anchor behaviour.


I've now committed the test and fixed it to contain what I think is
the correct behaviour (which, coincidentally, is what the code does
now, at least after this patch).

The `__N_o_<TAB>' thing is a pity, yes, but see my last reply for this 
(11346).


The patch contain the whole Test/54...

Bye
 Sven

Index: Doc/Zsh/compwid.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compwid.yo,v
retrieving revision 1.13
diff -u -r1.13 compwid.yo
--- Doc/Zsh/compwid.yo	2000/05/14 22:08:41	1.13
+++ Doc/Zsh/compwid.yo	2000/05/17 11:56:19
@@ -958,17 +958,21 @@
 complete strings with trailing numbers. Here one could use the simple
 form with only one anchor as in:
 
-example(compadd -M 'r:|[A-Z0-9]=* r:|=*' LikeTHIS FooHoo foo123 bar234)
+example(compadd -M 'r:|[A-Z0-9]=* r:|=*' LikeTHIS FooHoo 5foo123 5bar234)
 
-But with this, the string `tt(H)' would be completed to `tt(FooHoo)'
-em(and) `tt(LikeTHIS)' and `tt(2)' would be completed to the other two
+But with this, the string `tt(H)' would neither complete to `tt(FooHoo)'
+nor to `tt(LikeTHIS)' because in each case there is an uppercase
+letter before the `tt(H)' and that is matched by the anchor. Likewise, 
+a `tt(2)' would not be completed. In both cases this could be changed
+by using `tt(r:|[A-Z0-9]=**)', but then `tt(H)' completes to both
+`tt(LikeTHIS)' and `tt(FooHoo)' and a `tt(2)' matches the other
 strings because characters can be inserted before every uppercase
 letter and digit. To avoid this one would use:
 
-example(compadd -M 'r:[^A-Z0-9]||[A-Z0-9]=* r:|=*' \ 
+example(compadd -M 'r:[^A-Z0-9]||[A-Z0-9]=** r:|=*' \ 
     LikeTHIS FooHoo foo123 bar234)
 
-By using these two anchors, a `tt(H)' matches only uppercase `H's that 
+By using these two anchors, a `tt(H)' matches only uppercase `tt(H)'s that 
 are immediately preceded by something matching the left anchor
 `tt([^A-Z0-9])'. The effect is, of course, that `tt(H)' matches only
 the string `tt(FooHoo)', a `tt(2)' matches only `tt(bar234)' and so on.
Index: Src/Zle/comp.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/comp.h,v
retrieving revision 1.4
diff -u -r1.4 comp.h
--- Src/Zle/comp.h	2000/05/05 12:06:21	1.4
+++ Src/Zle/comp.h	2000/05/17 11:56:19
@@ -196,6 +196,7 @@
 #define CLF_LINE     32
 #define CLF_JOIN     64
 #define CLF_MATCHED 128
+#define CLF_SKIP    256
 
 /* Information for ambiguous completions. One for fignore ignored and   *
  * one for normal completion. */
Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.21
diff -u -r1.21 compcore.c
--- Src/Zle/compcore.c	2000/05/16 10:45:26	1.21
+++ Src/Zle/compcore.c	2000/05/17 11:56:19
@@ -1740,55 +1740,57 @@
 		    llpl -= gfl;
 		}
 	    }
-	    s = dat->ppre ? dat->ppre : dupstring("");
-	    if ((ml = match_str(lpre, s, &bpl, 0, NULL, 0, 0, 1)) >= 0) {
-		if (matchsubs) {
-		    Cline tmp = get_cline(NULL, 0, NULL, 0, NULL, 0, 0);
+	    if ((s = dat->ppre)) {
+		if ((ml = match_str(lpre, s, &bpl, 0, NULL, 0, 0, 1)) >= 0) {
+		    if (matchsubs) {
+			Cline tmp = get_cline(NULL, 0, NULL, 0, NULL, 0, 0);
 
-		    tmp->prefix = matchsubs;
-		    if (matchlastpart)
-			matchlastpart->next = tmp;
+			tmp->prefix = matchsubs;
+			if (matchlastpart)
+			    matchlastpart->next = tmp;
+			else
+			    matchparts = tmp;
+		    }
+		    pline = matchparts;
+		    lpre += ml;
+		    llpl -= ml;
+		    bcp = ml;
+		    bpadd = strlen(s) - ml;
+		} else {
+		    if (llpl <= lpl && strpfx(lpre, s))
+			lpre = dupstring("");
+		    else if (llpl > lpl && strpfx(s, lpre))
+			lpre += lpl;
 		    else
-			matchparts = tmp;
+			*argv = NULL;
+		    bcp = lpl;
 		}
-		pline = matchparts;
-		lpre += ml;
-		llpl -= ml;
-		bcp = ml;
-		bpadd = strlen(s) - ml;
-	    } else {
-		if (llpl <= lpl && strpfx(lpre, s))
-		    lpre = dupstring("");
-		else if (llpl > lpl && strpfx(s, lpre))
-		    lpre += lpl;
-		else
-		    *argv = NULL;
-		bcp = lpl;
 	    }
-	    s = dat->psuf ? dat->psuf : dupstring("");
-	    if ((ml = match_str(lsuf, s, &bsl, 0, NULL, 1, 0, 1)) >= 0) {
-		if (matchsubs) {
-		    Cline tmp = get_cline(NULL, 0, NULL, 0, NULL, 0, CLF_SUF);
+	    if ((s = dat->psuf)) {
+		if ((ml = match_str(lsuf, s, &bsl, 0, NULL, 1, 0, 1)) >= 0) {
+		    if (matchsubs) {
+			Cline tmp = get_cline(NULL, 0, NULL, 0, NULL, 0, CLF_SUF);
 
-		    tmp->suffix = matchsubs;
-		    if (matchlastpart)
-			matchlastpart->next = tmp;
+			tmp->suffix = matchsubs;
+			if (matchlastpart)
+			    matchlastpart->next = tmp;
+			else
+			    matchparts = tmp;
+		    }
+		    sline = revert_cline(matchparts);
+		    lsuf[llsl - ml] = '\0';
+		    llsl -= ml;
+		    bcs = ml;
+		    bsadd = strlen(s) - ml;
+		} else {
+		    if (llsl <= lsl && strsfx(lsuf, s))
+			lsuf = dupstring("");
+		    else if (llsl > lsl && strsfx(s, lsuf))
+			lsuf[llsl - lsl] = '\0';
 		    else
-			matchparts = tmp;
+			*argv = NULL;
+		    bcs = lsl;
 		}
-		sline = revert_cline(matchparts);
-		lsuf[llsl - ml] = '\0';
-		llsl -= ml;
-		bcs = ml;
-		bsadd = strlen(s) - ml;
-	    } else {
-		if (llsl <= lsl && strsfx(lsuf, s))
-		    lsuf = dupstring("");
-		else if (llsl > lsl && strsfx(s, lsuf))
-		    lsuf[llsl - lsl] = '\0';
-		else
-		    *argv = NULL;
-		bcs = lsl;
 	    }
 	    if (comppatmatch && *comppatmatch) {
 		int is = (*comppatmatch == '*');
Index: Src/Zle/compmatch.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compmatch.c,v
retrieving revision 1.13
diff -u -r1.13 compmatch.c
--- Src/Zle/compmatch.c	2000/05/15 09:34:12	1.13
+++ Src/Zle/compmatch.c	2000/05/17 11:56:20
@@ -411,7 +411,8 @@
 
     /* And add the cline. */
     if (wl || ll) {
-	n = get_cline(l, ll, w, wl, NULL, 0, flags);
+	n = get_cline(l, ll, w, wl, NULL, 0,
+		      flags | ((m && m->wlen == -2) ? CLF_SKIP : 0));
 	if (matchlastsub)
 	    matchlastsub->next = n;
 	else
@@ -1925,9 +1926,9 @@
 		Cline t, tn, tt, to = NULL;
 
 		for (t = n; (tn = t->next); t = tn)
-		    if (!(tn->flags & CLF_NEW)) {
+		    if (!(tn->flags & CLF_NEW) && (tn->flags & CLF_SKIP)) {
 			for (tt = o; (to = tt->next); tt = to)
-			    if (!(to->flags & CLF_NEW) &&
+			    if (!(to->flags & CLF_NEW) && (to->flags & CLF_SKIP) &&
 				cmp_anchors(tn, to, 1))
 				break;
 			if (to)
@@ -1953,8 +1954,9 @@
 		    n = n->next;
 		    continue;
 		} else {
-		    for (t = o; (to = t->next) && !cmp_anchors(n, to, 1);
-			 t = to);
+		    for (t = o; (to = t->next); t = to)
+			if ((to->flags & CLF_SKIP) && cmp_anchors(n, to, 1))
+			    break;
 
 		    if (to) {
 			diff = sub_join(n, o, to, 1);
@@ -1975,9 +1977,11 @@
 			continue;
 		    } else {
 			for (tt = NULL, t = n; (tn = t->next); t = tn) {
-			    for (tt = o;
-				 (to = tt->next) &&
-				     !cmp_anchors(tn, to, 1); tt = to);
+			    if (tn->flags & CLF_SKIP)
+				for (tt = o; (to = tt->next); tt = to)
+				    if ((to->flags & CLF_SKIP) &&
+					cmp_anchors(tn, to, 1))
+					break;
 			    if (to)
 				break;
 			}
Index: Test/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/.distfiles,v
retrieving revision 1.2
diff -u -r1.2 .distfiles
--- Test/.distfiles	2000/04/19 19:03:09	1.2
+++ Test/.distfiles	2000/05/17 11:56:20
@@ -5,5 +5,5 @@
     05command.ztst 06arith.ztst 07cond.ztst 08traps.ztst 09funcdef.ztst
     10prompt.ztst 11glob.ztst 12procsubst.ztst 13parameter.ztst
     50cd.ztst 51xtrace.ztst 52zregexparse.ztst
-    53completion.ztst
+    53completion.ztst 54compmatch.ztst
 '
Index: Test/54compmatch.ztst
===================================================================
RCS file: 54compmatch.ztst
diff -N 54compmatch.ztst
--- /dev/null	Tue May  5 13:32:27 1998
+++ 54compmatch.ztst	Wed May 17 04:56:20 2000
@@ -0,0 +1,488 @@
+# Tests for completion system matching control
+
+# Most tests follow this format:
+#	test_code $matcher_string selection_list
+#	comptest -c "$code" $' tst input_string'
+# test_code generates the string $codem which sets what words the completion
+# should be selecting from.  The comptest function actually performs the
+# completion test, using the completion function generated by test_code.
+#
+# This test also tests error conditions that compadd reports, so output also
+# contains the compadd output.
+
+%prep
+  zmodload -i zsh/zpty
+
+  TERM=vt100
+  export ZTST_testdir ZTST_srcdir TERM
+  comptest () { $ZTST_testdir/../Src/zsh -f $ZTST_srcdir/comptest -z $ZTST_testdir/../Src/zsh -d $ZTST_testdir/compdump.tmp "$@" }
+
+  mkdir match.tmp
+  cd match.tmp
+
+
+  list1=(IndianRed IndianRed2 IndianRed3 IndianRed4)
+  test_code () {
+	matcher=$1;
+	list=$2;
+	code="compdef _tst tst ; _tst () { echo -n '<COMPADD>';compadd -M '"
+	code="$code$matcher"
+	code="$code'  - ${(P)list} ; echo  -n '</COMPADD>'}"
+  }
+
+	 
+
+%test
+
+
+ test_code z: list1
+ comptest  -c "$code" $'tst \t'
+0:Match Error for "z:"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: unknown match specification character `z'}
+
+ test_code m: list1
+ comptest  -c "$code" $'tst \t'
+0:Match Error for "m:"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: missing patterns}
+
+ test_code M: list1
+ comptest -c "$code" $'tst \t'
+0:Match Error for "M:"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: missing patterns}
+
+ test_code r: list1
+ comptest -c "$code" $'tst \t'
+0:Match Error "r:"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: missing patterns}
+
+ test_code R: list1
+ comptest -c "$code" $'tst \t'
+0:Match Error "R:"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: missing patterns}
+
+ test_code l: list1
+ comptest -c "$code" $'tst \t'
+0:Match Error for "l:"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: missing patterns}
+
+ test_code L: list1
+ comptest -c "$code" $'tst \t'
+0:Match Error for "L:"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: missing patterns}
+
+ test_code 'm:{0-9' list1
+ comptest -c "$code" $'tst \t'
+0:Match Error for "m:{0-9"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: unterminated character class}
+
+ test_code 'm:{0-9}' list1
+ comptest -c "$code" $'tst \t'
+0:Match Error for "m:{0-9}"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: missing word pattern}
+
+ test_code 'm:{0-9}={' list1
+ comptest -c "$code" $'tst \t'
+0:Match Error for "m:{0-9}={"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: unterminated character class}
+
+ test_code 'm:{0-9}={0-' list1
+ comptest -c "$code" $'tst \t'
+0:Match Error for "m:{0-9}={0-"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: unterminated character class}
+
+ test_code 'm:{0-9}={-' list1
+ comptest -c "$code" $'tst \t'
+0:Match Error for "m:{0-9}={-"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: unterminated character class}
+
+ test_code r: list1
+ comptest -c "$code" $'tst \t'
+0:Match Error "r:"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: missing patterns}
+
+  example1_list=(
+	kshoptionprint        shglob              
+	listambiguous         shinstdin           
+	listbeep              shnullcmd           
+	listpacked            shoptionletters     
+	listrowsfirst         shortloops          
+	listtypes             shwordsplit
+   )
+ options_matcher='L:|[nN][oO]= M:_= M:{A-Z}={a-z}'
+ test_code $options_matcher example1_list
+ comptest -c "$code" $'tst nolistbee\t'
+0:Documentation example for options, input "nolistbee"
+>line: {tst nolistbeep }{}
+>COMPADD:{}
+
+
+ test_code $options_matcher example1_list
+ comptest -c "$code" $'tst list_bee\t'
+0:Documentation example for options, input "list_bee"
+>line: {tst list_beep }{}
+>COMPADD:{}
+
+ test_code $options_matcher example1_list
+ comptest -c "$code" $'tst ListBee\t'
+0:Documentation example for options, input "ListBee"
+>line: {tst ListBeep }{}
+>COMPADD:{}
+
+ test_code $options_matcher example1_list
+ comptest -c "$code" $'tst NOList\tB\t'
+0:Documentation example for options, input "NOList"
+>line: {tst NOList}{}
+>COMPADD:{}
+>NO:{NOListambiguous}
+>NO:{NOListbeep}
+>NO:{NOListpacked}
+>NO:{NOListrowsfirst}
+>NO:{NOListtypes}
+>line: {tst NOListBeep }{}
+>COMPADD:{}
+
+
+ test_code $options_matcher example1_list
+ comptest -c "$code" $'tst NO_List\t__\tB\t'
+0:Documentation example for options, input "NO_List\t__\tB\t"
+>line: {tst NO_List}{}
+>COMPADD:{}
+>NO:{NO_Listambiguous}
+>NO:{NO_Listbeep}
+>NO:{NO_Listpacked}
+>NO:{NO_Listrowsfirst}
+>NO:{NO_Listtypes}
+>line: {tst NO_List__}{}
+>COMPADD:{}
+>NO:{NO_List__ambiguous}
+>NO:{NO_List__beep}
+>NO:{NO_List__packed}
+>NO:{NO_List__rowsfirst}
+>NO:{NO_List__types}
+>line: {tst NO_List__Beep }{}
+>COMPADD:{}
+
+ test_code $options_matcher example1_list
+ comptest -c "$code" $'tst __\tN\t__o\t___\tlist_\tbeep__\t'
+0:Documentation example for options, input "__\tN\t__o\t___\tlist_\tbeep__\t" 
+>line: {tst __}{}
+>COMPADD:{}
+>NO:{__kshoptionprint}
+>NO:{__listambiguous}
+>NO:{__listbeep}
+>NO:{__listpacked}
+>NO:{__listrowsfirst}
+>NO:{__listtypes}
+>NO:{__shglob}
+>NO:{__shinstdin}
+>NO:{__shnullcmd}
+>NO:{__shoptionletters}
+>NO:{__shortloops}
+>NO:{__shwordsplit}
+>line: {tst __N}{}
+>COMPADD:{}
+>line: {tst __N__o}{}
+>COMPADD:{}
+>line: {tst __N__o___}{}
+>COMPADD:{}
+>line: {tst __N__o___list_}{}
+>COMPADD:{}
+>line: {tst __N__o___list_beep__}{}
+>COMPADD:{}
+
+ test_code $options_matcher example1_list
+ comptest -c "$code" $'tst __\tNo\t___\tlist_\tbeep__\t'
+0:Documentation example for options, input "__\tNo\t___\tlist_\tbeep__\t" 
+>line: {tst __}{}
+>COMPADD:{}
+>NO:{__kshoptionprint}
+>NO:{__listambiguous}
+>NO:{__listbeep}
+>NO:{__listpacked}
+>NO:{__listrowsfirst}
+>NO:{__listtypes}
+>NO:{__shglob}
+>NO:{__shinstdin}
+>NO:{__shnullcmd}
+>NO:{__shoptionletters}
+>NO:{__shortloops}
+>NO:{__shwordsplit}
+>line: {tst __No}{}
+>COMPADD:{}
+>line: {tst __No___}{}
+>COMPADD:{}
+>line: {tst __No___list_}{}
+>COMPADD:{}
+>line: {tst __No___list_beep__}{}
+>COMPADD:{}
+
+
+ test_code $options_matcher example1_list
+ comptest -c "$code" $'tst ___\tlist_\tbeep__\t'
+0:Documentation example for options, input "___\tlist_\tbeep__\t" 
+>line: {tst ___}{}
+>COMPADD:{}
+>NO:{___kshoptionprint}
+>NO:{___listambiguous}
+>NO:{___listbeep}
+>NO:{___listpacked}
+>NO:{___listrowsfirst}
+>NO:{___listtypes}
+>NO:{___shglob}
+>NO:{___shinstdin}
+>NO:{___shnullcmd}
+>NO:{___shoptionletters}
+>NO:{___shortloops}
+>NO:{___shwordsplit}
+>line: {tst ___list_}{}
+>COMPADD:{}
+>NO:{___list_ambiguous}
+>NO:{___list_beep}
+>NO:{___list_packed}
+>NO:{___list_rowsfirst}
+>NO:{___list_types}
+>line: {tst ___list_beep__ }{}
+>COMPADD:{}
+
+ lower_insensitive_M="M:{a-z}={A-Z}"
+ lower_insensitive_m="m:{a-z}={A-Z}"
+ example2_list=(ABC Abc abc)
+ test_code $lower_insensitive_M example2_list
+ comptest -c "$code" $'tst ab\tC\t'
+0:Documentation example for lowercase insenitive M, input "ab\tC\t"
+>line: {tst ab}{}
+>COMPADD:{}
+>NO:{abC}
+>NO:{abc}
+>line: {tst abC }{}
+>COMPADD:{}
+
+ test_code $lower_insensitive_m example2_list
+ comptest -c "$code" $'tst A\t\t'
+0:Documentation example for lowercase insenitive m, input "A\t\t" 
+>line: {tst A}{}
+>COMPADD:{}
+>NO:{ABC}
+>NO:{Abc}
+>line: {tst ABC}{}
+>COMPADD:{}
+
+ example3_list=(ABC Abc abc)
+ case_insensitive_M="M:{a-zA-Z}={A-Za-z}"
+ case_insensitive_m="m:{a-zA-Z}={A-Za-z}"
+ test_code $case_insensitive_M example3_list
+ comptest -c "$code" $'tst aB\t\t'
+0:Documentation example for case insenitive M, input "aB\t\t"
+>line: {tst aB}{}
+>COMPADD:{}
+>NO:{aBC}
+>NO:{aBc}
+>line: {tst aBC}{}
+>COMPADD:{}
+
+
+ test_code $case_insensitive_m example3_list
+ comptest -c "$code" $'tst aB\t\t'
+0:Documentation example for case insenitive m, input "aB\t\t"
+>line: {tst a}{BC}
+>COMPADD:{}
+>line: {tst a}{BC}
+>COMPADD:{}
+>NO:{ABC}
+>NO:{Abc}
+>NO:{abc}
+
+  example4_matcher='r:|.=* r:|=*'
+  example4_list=(comp.sources.unix comp.sources.misc 
+  comp.graphics.algorithms comp.graphics.animation comp.graphics.api
+  comp.graphics.apps comp.graphics.misc comp.graphics.packages
+  comp.graphics.rendering comp.graphics.visualization comp.graphics.apps.alias
+  comp.graphics.apps.gimp comp.graphics.apps.gnuplot
+  comp.graphics.apps.lightwave comp.graphics.apps.pagemaker
+  comp.graphics.apps.paint-shop-pro comp.graphics.apps.photoshop
+  comp.graphics.apps.softimage comp.graphics.apps.ulead
+  comp.graphics.rendering.misc comp.graphics.rendering.raytracing
+  comp.graphics.rendering.renderman)
+ test_code $example4_matcher example4_list
+ comptest -c "$code" $'tst c.s.u\t'
+0:Documentation example using input c.s.u
+>line: {tst comp.sources.unix }{}
+>COMPADD:{}
+
+ test_code $example4_matcher example4_list
+ comptest -c "$code" $'tst c.g.\ta\t.\tp\ta\tg\t'
+0:Documentation example using input c.g.\ta\t.\tp\ta\tg\t
+>line: {tst comp.graphics.}{}
+>COMPADD:{}
+>line: {tst comp.graphics.a}{}
+>COMPADD:{}
+>NO:{comp.graphics.algorithms}
+>NO:{comp.graphics.animation}
+>NO:{comp.graphics.api}
+>NO:{comp.graphics.apps}
+>NO:{comp.graphics.apps.alias}
+>NO:{comp.graphics.apps.gimp}
+>NO:{comp.graphics.apps.gnuplot}
+>NO:{comp.graphics.apps.lightwave}
+>NO:{comp.graphics.apps.pagemaker}
+>NO:{comp.graphics.apps.paint-shop-pro}
+>NO:{comp.graphics.apps.photoshop}
+>NO:{comp.graphics.apps.softimage}
+>NO:{comp.graphics.apps.ulead}
+>line: {tst comp.graphics.apps.}{}
+>COMPADD:{}
+>line: {tst comp.graphics.apps.p}{}
+>COMPADD:{}
+>NO:{comp.graphics.apps.pagemaker}
+>NO:{comp.graphics.apps.paint-shop-pro}
+>NO:{comp.graphics.apps.photoshop}
+>line: {tst comp.graphics.apps.pa}{}
+>COMPADD:{}
+>NO:{comp.graphics.apps.pagemaker}
+>NO:{comp.graphics.apps.paint-shop-pro}
+>line: {tst comp.graphics.apps.pagemaker }{}
+>COMPADD:{}
+
+ test_code $example4_matcher example4_list
+ comptest -c "$code" $'tst c...pag\t'
+0:Documentation example using input c...pag\t
+>line: {tst comp.graphics.apps.pagemaker }{}
+>COMPADD:{}
+
+ test_code $example4_matcher example4_list
+ comptest -c "$code" $'tst c...pa\tg\t'
+0:Documentation example using input c...pa\tg\t
+>line: {tst comp.graphics.apps.pa}{}
+>COMPADD:{}
+>line: {tst comp.graphics.apps.pagemaker }{}
+>COMPADD:{}
+
+ example5_matcher='r:|[.,_-]=* r:|=*'
+ example5_list=(veryverylongfile.c veryverylongheader.h)
+ test_code $example5_matcher example5_list
+ comptest -c "$code" $'tst  v.c\tv.h\t'
+0:Documentation example using input v.c\t
+>line: {tst  veryverylongfile.c }{}
+>COMPADD:{}
+>line: {tst  veryverylongfile.c veryverylongheader.h }{}
+>COMPADD:{}
+
+
+ example6_list=(LikeTHIS FooHoo 5foo123 5bar234)
+ test_code 'r:|[A-Z0-9]=* r:|=*' example6_list
+ comptest -c "$code" $'tst H\t'
+0:Documentation example using "r:|[A-Z0-9]=* r:|=*", input H
+>line: {tst H}{}
+>COMPADD:{}
+
+ test_code 'r:|[A-Z0-9]=* r:|=*' example6_list
+ comptest -c "$code" $'tst 2\t'
+0:Documentation example using "r:|[A-Z0-9]=* r:|=*", input 2
+>line: {tst 2}{}
+>COMPADD:{}
+
+ test_code 'r:|[A-Z0-9]=** r:|=*' example6_list
+ comptest -c "$code" $'tst H\t'
+0:Documentation example using "r:|[A-Z0-9]=* r:|=*", input 2
+>line: {tst H}{}
+>COMPADD:{}
+>NO:{FooHoo}
+>NO:{LikeTHIS}
+
+ test_code 'r:|[A-Z0-9]=** r:|=*' example6_list
+ comptest -c "$code" $'tst 2\t\t'
+0:Documentation example using "r:|[A-Z0-9]=* r:|=*", input 2
+>line: {tst 523}{}
+>COMPADD:{}
+>line: {tst 523}{}
+>COMPADD:{}
+>NO:{5bar234}
+>NO:{5foo123}
+
+ example7_matcher="r:[^A-Z0-9]||[A-Z0-9]=** r:|=*"
+ example7_list=($example6_list)
+ test_code $example7_matcher example7_list
+ comptest -c "$code" $'tst H\t2\t'
+0:Documentation example using "r:[^A-Z0-9]||[A-Z0-9]=** r:|=*"
+>line: {tst FooHoo }{}
+>COMPADD:{}
+>line: {tst FooHoo 5bar234 }{}
+>COMPADD:{}
+
+
+ workers_7311_matcher="m:{a-z}={A-Z} r:|[.,_-]=* r:|=*"
+ workers_7311_list=(Abc-Def-Ghij.txt Abc-def.ghi.jkl_mno.pqr.txt Abc_def_ghi_jkl_mno_pqr.txt)
+ test_code $workers_7311_matcher workers_7311_list
+ comptest -c "$code" $'tst a-a\t'
+0:Bug from workers 7311
+>line: {tst a-a}{}
+>COMPADD:{}
+
+ test_code $workers_7311_matcher workers_7311_list
+ comptest -c "$code" $'tst a\t\t-d.\t'
+0:Bug from workers_7311 
+>line: {tst Abc}{}
+>COMPADD:{}
+>line: {tst Abc}{}
+>COMPADD:{}
+>NO:{Abc-Def-Ghij.txt}
+>NO:{Abc-def.ghi.jkl_mno.pqr.txt}
+>NO:{Abc_def_ghi_jkl_mno_pqr.txt}
+>line: {tst Abc-def.ghi.jkl_mno.pqr.txt }{}
+>COMPADD:{}
+
+ workers_10886_matcher="r:|[A-Z0-9]=* r:|=*"
+ workers_10886_list=(BW UWB W)
+ test_code $workers_10886_matcher workers_10886_list
+ comptest -c "$code" $'tst W\t'
+0:Bug from workers 10886
+>line: {tst W }{}
+>COMPADD:{}
+
+ workers_11081_matcher='m:{a-zA-Z}={A-Za-z} r:|[.,_-]=* r:[^A-Z0-9]||[A-Z0-9]=* r:[A-Z0-9]||[^A-Z0-9]=* r:[^0-9]||[0-9]=* r:|=*'
+ workers_11081_list=(build.out build.out1 build.out2)
+ test_code $workers_11081_matcher workers_11081_list
+ comptest -c "$code" $'tst bui\t\t\t'
+0:Bug from workers 11081
+>line: {tst build.out}{}
+>COMPADD:{}
+>line: {tst build.out}{}
+>COMPADD:{}
+>NO:{build.out}
+>NO:{build.out1}
+>NO:{build.out2}
+>line: {tst build.out}{}
+>COMPADD:{}
+
+
+ workers_11388_matcher='r:|[:.]=* r:|=*'
+ workers_11388_list=(a.b:0 c.d:1)
+ test_code $workers_11388_matcher workers_11388_list
+ comptest -c "$code" $'tst :\t'
+0:Non-bug from workers 11388
+>line: {tst :}{}
+>COMPADD:{}
+
+ workers_11388_matcher='r:|[:.]=** r:|=*'
+ workers_11388_list=(a.b:0 c.d:1)
+ test_code $workers_11388_matcher workers_11388_list
+ comptest -c "$code" $'tst :\t'
+0:Non-bug from workers 11388
+>line: {tst }{.:}
+>COMPADD:{}
+
+%clean
+exit 0
Index: Test/comptest
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/comptest,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 comptest
--- Test/comptest	2000/03/24 12:48:02	1.1.1.7
+++ Test/comptest	2000/05/17 11:56:20
@@ -13,6 +13,7 @@
 zsh=${ZSH:-zsh}
 termcap_ce="$(echotc ce)"
 
+debug=yes
 while getopts Dd:c:z: opt; do
   case $opt in
     D) debug=yes;;
@@ -104,7 +105,7 @@
   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
+  while (( ${(N)log#*(#b)(<LC><(??)><RC>(*)<EC>|<DESCRIPTION>(*)</DESCRIPTION>|<MESSAGE>(*)</MESSAGE>|<COMPADD>(*)</COMPADD>)} )); do
     log="${log[$mend[1]+1,-1]}"
     if (( 0 <= $mbegin[2] )); then
       if [[ $match[2] != TC && $match[3] != \ # ]]; then
@@ -114,6 +115,9 @@
       print -lr "DESCRIPTION:{$match[4]}"
     elif (( 0 <= $mbegin[5] )); then
       print -lr "MESSAGE:{$match[5]}"
+    elif (( 0 <= $mbegin[6] )); then
+      result=`echo $match[6] | tr -d '\012\015'`
+      print -lr "COMPADD:{$result}"
     fi
   done
 done

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


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

* Re: PATCH: Completion matching control test. (Try 2)
@ 2000-05-18  2:35 Felix Rosencrantz
  0 siblings, 0 replies; 9+ messages in thread
From: Felix Rosencrantz @ 2000-05-18  2:35 UTC (permalink / raw)
  To: zsh-workers

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

> On May 16,  9:11pm, Felix Rosencrantz wrote:
> } --- Bart Schaefer <schaefer@candle.brasslantern.com> wrote:
> } > This works for me:
> } > 
> } > 	print -lr "COMPADD:{${match[6]//[$'\r\n']/}}"
> } 
> } Great. Works for me, too.  Will use that.  I'll send a patch when the
> } changes make it into the repository.
There's no need to call "tr".  Where possible we should use zsh.
So here's the patch.

-FR.

__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/

[-- Attachment #2: patch3.txt --]
[-- Type: text/plain, Size: 495 bytes --]

Index: Test/comptest
===================================================================
--- zsh/Test/,comptest	Wed May 17 05:31:32 2000
+++ zsh/Test/comptest	Wed May 17 19:23:40 2000
@@ -107,8 +107,7 @@
       elif (( 0 <= $mbegin[5] )); then
 	print -lr "MESSAGE:{$match[5]}"
       elif (( 0 <= $mbegin[6] )); then
-        result=`echo $match[6] | tr -d '\012\015'`
-        print -lr "COMPADD:{$result}"
+        print -lr "COMPADD:{${${match[6]}//[$'\r\n']/}}"
       fi
     done
   done

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

* Re: PATCH: Completion matching control test. (Try 2)
  2000-05-17 10:33 Sven Wischnowsky
@ 2000-05-17 12:30 ` Tanaka Akira
  0 siblings, 0 replies; 9+ messages in thread
From: Tanaka Akira @ 2000-05-17 12:30 UTC (permalink / raw)
  To: zsh-workers

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

> I'm working on it and will commit it when I'm finished, which may take 
> some time because those tests are so damn slow. I wished there were a
> way to make comptest initialise the completion system only once.

This makes completion tests to start zsh only once for each test file.

Index: Test/comptest
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/comptest,v
retrieving revision 1.2
diff -u -r1.2 comptest
--- Test/comptest	2000/05/17 11:59:33	1.2
+++ Test/comptest	2000/05/17 12:24:14
@@ -1,39 +1,34 @@
-#!/usr/local/bin/zsh -f
-
-[[ -d $ZTST_testdir/Modules/zsh ]] && module_path=( $ZTST_testdir/Modules )
-
-zmodload -i zsh/zpty
-setopt extendedglob
+comptestinit () {
+  setopt extendedglob
+  [[ -d $ZTST_testdir/Modules/zsh ]] && module_path=( $ZTST_testdir/Modules )
+  fpath=( $ZTST_srcdir/../(Completion|Functions)/*~*/CVS(/) )
+
+  zmodload -i zsh/zpty
+
+  comptest_zsh=${ZSH:-zsh}
+  termcap_ce="$(echotc ce)"
+
+  while getopts z: opt; do
+    case $opt in
+      z) comptest_zsh="$OPTARG";;
+    esac
+  done
+  (( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
 
-fpath=( $ZTST_srcdir/../(Completion|Functions)/*~*/CVS(/) )
+  export PS1="<PROMPT>"
+  zpty zsh "$comptest_zsh" -f
 
-debug=
-dump=(-D)
-code=
-zsh=${ZSH:-zsh}
-termcap_ce="$(echotc ce)"
-
-debug=yes
-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="$*"
-
-tmp=/tmp/comptest.$$
-
-cat <<End >$tmp
-module_path=( $module_path )
-fpath=( $fpath )
+  zpty -r zsh log1 "*<PROMPT>*" || { 
+    print "first prompt doesn't appered."
+    return 1
+  }
+
+  comptesteval \
+"module_path=( $module_path )" \
+"fpath=( $fpath )" \
+"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>'" \
+'LISTMAX=10000000
 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
@@ -49,7 +44,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
 }
@@ -61,8 +56,9 @@
 }
 finish () {
   print "<WIDGET><finish>"
-  sleep 1
-  exit 0
+  zle kill-whole-line
+  zle clear-screen
+  zle -R
 }
 zle -N expand-or-complete-with-report
 zle -N list-choices-with-report
@@ -70,54 +66,50 @@
 bindkey "^I" expand-or-complete-with-report
 bindkey "^D" list-choices-with-report
 bindkey "^Z" finish
-$code
-End
+'
+}
 
-export PS1="<PROMPT>"
-zpty zsh "$zsh" -f
+comptesteval () {
+  local tmp=/tmp/comptest.$$
 
-zpty -r zsh log1 "*<PROMPT>*" || { 
-  print first prompt doesn\'t appered.
-  exit 1
-}
-
-zpty -w zsh ". $tmp"
-zpty -r zsh log2 "*<PROMPT>*" || {
-  print second prompt doesn\'t appered.
-  exit 1
-}
-rm $tmp
-
-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
-fi
-
-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>|<COMPADD>(*)</COMPADD>)} )); do
-    log="${log[$mend[1]+1,-1]}"
-    if (( 0 <= $mbegin[2] )); then
-      if [[ $match[2] != TC && $match[3] != \ # ]]; then
-	print -lr "$match[2]:{${match[3]%$termcap_ce}}"
-      fi
-    elif (( 0 <= $mbegin[4] )); then
-      print -lr "DESCRIPTION:{$match[4]}"
-    elif (( 0 <= $mbegin[5] )); then
-      print -lr "MESSAGE:{$match[5]}"
-    elif (( 0 <= $mbegin[6] )); then
-      result=`echo $match[6] | tr -d '\012\015'`
-      print -lr "COMPADD:{$result}"
+  print -lr - "$@" > $tmp
+  zpty -w zsh ". $tmp"
+  zpty -r zsh log_eval "*<PROMPT>*" || {
+    print "prompt doesn't appered."
+    return 1
+  }
+  rm $tmp
+}
+
+comptest () {
+  input="$*"
+  zpty -n -w zsh "$input"$'\C-Z'
+  zpty -r zsh log "*<WIDGET><finish>*<PROMPT>*" || {
+    print "finish widget doesn't invoked."
+    return 1
+  }
+
+  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>|<COMPADD>(*)</COMPADD>)} )); do
+      log="${log[$mend[1]+1,-1]}"
+      if (( 0 <= $mbegin[2] )); then
+	if [[ $match[2] != TC && $match[3] != \ # ]]; then
+	  print -lr "$match[2]:{${match[3]%$termcap_ce}}"
+	fi
+      elif (( 0 <= $mbegin[4] )); then
+	print -lr "DESCRIPTION:{$match[4]}"
+      elif (( 0 <= $mbegin[5] )); then
+	print -lr "MESSAGE:{$match[5]}"
+      elif (( 0 <= $mbegin[6] )); then
+        result=`echo $match[6] | tr -d '\012\015'`
+        print -lr "COMPADD:{$result}"
+      fi
+    done
   done
-done
+}
Index: Test/53completion.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/53completion.ztst,v
retrieving revision 1.3
diff -u -r1.3 53completion.ztst
--- Test/53completion.ztst	2000/05/17 10:28:15	1.3
+++ Test/53completion.ztst	2000/05/17 12:24:14
@@ -1,15 +1,13 @@
 # Tests for completion system.
 
 %prep
-  zmodload -i zsh/zpty
+  . $ZTST_srcdir/comptest
 
-  TERM=vt100
-  export ZTST_testdir ZTST_srcdir TERM
-  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
 
+  comptestinit -z $ZTST_testdir/../Src/zsh
+
   mkdir dir1
   mkdir dir2
   touch file1
@@ -32,7 +30,8 @@
 >line: {: dir1/}{}
 >line: {: dir2/}{}
 
-  comptest -c '_users () { compadd user1 user2 }' $': ~\t\t\t\t\t'
+  comptesteval '_users () { compadd user1 user2 }'
+  comptest $': ~\t\t\t\t\t'
 0:tilde
 >line: {: ~user}{}
 >line: {: ~user}{}
@@ -41,100 +40,109 @@
 >line: {: ~user1}{}
 >line: {: ~user2}{}
 >line: {: ~user1}{}
+
+  comptest $'echo ;:\C-b\C-b\t'
+0:tilde
+>line: {echo }{;:}
+>DESCRIPTION:{file}
+>DI:{dir1}
+>DI:{dir2}
+>FI:{file1}
+>FI:{file2}
 
- code='compdef _tst tst; _tst () { _arguments ":desc1:(arg1)" }'
- comptest -c "$code" $'tst \t'
+ comptesteval 'compdef _tst tst; _tst () { _arguments ":desc1:(arg1)" }'
+ comptest $'tst \t'
 0:_arguments
 >line: {tst arg1 }{}
 
- comptest -c "$code" $'tst a\t'
+ comptest $'tst a\t'
 0:_arguments
 >line: {tst arg1 }{}
 
- comptest -c "$code" $'tst ar\t'
+ comptest $'tst ar\t'
 0:_arguments
 >line: {tst arg1 }{}
 
- comptest -c "$code" $'tst arg\t'
+ comptest $'tst arg\t'
 0:_arguments
 >line: {tst arg1 }{}
 
- comptest -c "$code" $'tst arg1\t'
+ comptest $'tst arg1\t'
 0:_arguments
 >line: {tst arg1 }{}
 
- comptest -c "$code" $'tst r\t'
+ comptest $'tst r\t'
 0:_arguments
 >line: {tst r}{}
 
- comptest -c "$code" $'tst x\t'
+ comptest $'tst x\t'
 0:_arguments
 >line: {tst x}{}
 
- comptest -c "$code" $'tst a \t'
+ comptest $'tst a \t'
 0:_arguments
 >line: {tst a }{}
 >MESSAGE:{no more arguments}
 
- comptest -c "$code" $'tst a b \t'
+ comptest $'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'
+ comptesteval 'compdef _tst tst; _tst () { _arguments ":desc1:(a b)" }'
+ comptest $'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'
+ comptesteval 'compdef _tst tst; _tst () { _arguments ":desc1:(arg1)" ":desc2:(arg2)" ":desc3:(arg3)" }'
+ comptest $'tst \t'
 0:_arguments
 >line: {tst arg1 }{}
 
- comptest -c "$code" $'tst arg1 \t'
+ comptest $'tst arg1 \t'
 0:_arguments
 >line: {tst arg1 arg2 }{}
 
- comptest -c "$code" $'tst arg1 arg2 \t'
+ comptest $'tst arg1 arg2 \t'
 0:_arguments
 >line: {tst arg1 arg2 arg3 }{}
 
- comptest -c "$code" $'tst \C-D'
+ comptest $'tst \C-D'
 0:_arguments
 >DESCRIPTION:{desc1}
 >NO:{arg1}
 
- code='compdef _tst tst; _tst () { _arguments "-\+[opt]" }'
- comptest -c "$code" $'tst -\C-D'
+ comptesteval 'compdef _tst tst; _tst () { _arguments "-\+[opt]" }'
+ comptest $'tst -\C-D'
 0:_arguments
 >DESCRIPTION:{option}
 >NO:{-+ -- opt}
 
- code='compdef _tst tst; _tst () { _arguments "1:desc1:(arg1)" }'
- comptest -c "$code" $'tst \t'
+ comptesteval 'compdef _tst tst; _tst () { _arguments "1:desc1:(arg1)" }'
+ comptest $'tst \t'
 0:_arguments
 >line: {tst arg1 }{}
 
- code='compdef _tst tst; _tst () { _arguments "-x" ":arg:" }'
- comptest -c "$code" $'tst -\t'
+ comptesteval 'compdef _tst tst; _tst () { _arguments "-x" ":arg:" }'
+ comptest $'tst -\t'
 0:_arguments
 >line: {tst -}{}
 >MESSAGE:{arg}
 
- code='compdef _tst tst; _tst () { _arguments "-x:arg:" }'
- comptest -c "$code" $'tst -x\t'
+ comptesteval 'compdef _tst tst; _tst () { _arguments "-x:arg:" }'
+ comptest $'tst -x\t'
 0:_arguments
 >line: {tst -x }{}
 
- code='
+ comptesteval '
    compdef _tst tst
    _tst () { _arguments "-a" "*::rest:_tst2" }
    _tst2 () { compadd - -b }
  '
- comptest -c "$code" $'tst arg -\t'
+ comptest $'tst arg -\t'
 0:_arguments
 >line: {tst arg -b }{}
 
Index: Test/54compmatch.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/54compmatch.ztst,v
retrieving revision 1.1
diff -u -r1.1 54compmatch.ztst
--- Test/54compmatch.ztst	2000/05/17 11:59:33	1.1
+++ Test/54compmatch.ztst	2000/05/17 12:24:14
@@ -11,15 +11,12 @@
 # contains the compadd output.
 
 %prep
-  zmodload -i zsh/zpty
+  . $ZTST_srcdir/comptest
 
-  TERM=vt100
-  export ZTST_testdir ZTST_srcdir TERM
-  comptest () { $ZTST_testdir/../Src/zsh -f $ZTST_srcdir/comptest -z $ZTST_testdir/../Src/zsh -d $ZTST_testdir/compdump.tmp "$@" }
-
   mkdir match.tmp
   cd match.tmp
 
+  comptestinit -z $ZTST_testdir/../Src/zsh
 
   list1=(IndianRed IndianRed2 IndianRed3 IndianRed4)
   test_code () {
@@ -28,87 +25,87 @@
 	code="compdef _tst tst ; _tst () { echo -n '<COMPADD>';compadd -M '"
 	code="$code$matcher"
 	code="$code'  - ${(P)list} ; echo  -n '</COMPADD>'}"
+	comptesteval "$code"
   }
 
 	 
 
 %test
 
-
  test_code z: list1
- comptest  -c "$code" $'tst \t'
+ comptest  $'tst \t'
 0:Match Error for "z:"
 >line: {tst }{}
 >COMPADD:{_tst:compadd: unknown match specification character `z'}
 
  test_code m: list1
- comptest  -c "$code" $'tst \t'
+ comptest  $'tst \t'
 0:Match Error for "m:"
 >line: {tst }{}
 >COMPADD:{_tst:compadd: missing patterns}
 
  test_code M: list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
 0:Match Error for "M:"
 >line: {tst }{}
 >COMPADD:{_tst:compadd: missing patterns}
 
  test_code r: list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
 0:Match Error "r:"
 >line: {tst }{}
 >COMPADD:{_tst:compadd: missing patterns}
 
  test_code R: list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
 0:Match Error "R:"
 >line: {tst }{}
 >COMPADD:{_tst:compadd: missing patterns}
 
  test_code l: list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
 0:Match Error for "l:"
 >line: {tst }{}
 >COMPADD:{_tst:compadd: missing patterns}
 
  test_code L: list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
 0:Match Error for "L:"
 >line: {tst }{}
 >COMPADD:{_tst:compadd: missing patterns}
 
  test_code 'm:{0-9' list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
 0:Match Error for "m:{0-9"
 >line: {tst }{}
 >COMPADD:{_tst:compadd: unterminated character class}
 
  test_code 'm:{0-9}' list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
 0:Match Error for "m:{0-9}"
 >line: {tst }{}
 >COMPADD:{_tst:compadd: missing word pattern}
 
  test_code 'm:{0-9}={' list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
 0:Match Error for "m:{0-9}={"
 >line: {tst }{}
 >COMPADD:{_tst:compadd: unterminated character class}
 
  test_code 'm:{0-9}={0-' list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
 0:Match Error for "m:{0-9}={0-"
 >line: {tst }{}
 >COMPADD:{_tst:compadd: unterminated character class}
 
  test_code 'm:{0-9}={-' list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
 0:Match Error for "m:{0-9}={-"
 >line: {tst }{}
 >COMPADD:{_tst:compadd: unterminated character class}
 
  test_code r: list1
- comptest -c "$code" $'tst \t'
+ comptest $'tst \t'
 0:Match Error "r:"
 >line: {tst }{}
 >COMPADD:{_tst:compadd: missing patterns}
@@ -123,26 +120,26 @@
    )
  options_matcher='L:|[nN][oO]= M:_= M:{A-Z}={a-z}'
  test_code $options_matcher example1_list
- comptest -c "$code" $'tst nolistbee\t'
+ comptest $'tst nolistbee\t'
 0:Documentation example for options, input "nolistbee"
 >line: {tst nolistbeep }{}
 >COMPADD:{}
 
 
  test_code $options_matcher example1_list
- comptest -c "$code" $'tst list_bee\t'
+ comptest $'tst list_bee\t'
 0:Documentation example for options, input "list_bee"
 >line: {tst list_beep }{}
 >COMPADD:{}
 
  test_code $options_matcher example1_list
- comptest -c "$code" $'tst ListBee\t'
+ comptest $'tst ListBee\t'
 0:Documentation example for options, input "ListBee"
 >line: {tst ListBeep }{}
 >COMPADD:{}
 
  test_code $options_matcher example1_list
- comptest -c "$code" $'tst NOList\tB\t'
+ comptest $'tst NOList\tB\t'
 0:Documentation example for options, input "NOList"
 >line: {tst NOList}{}
 >COMPADD:{}
@@ -156,7 +153,7 @@
 
 
  test_code $options_matcher example1_list
- comptest -c "$code" $'tst NO_List\t__\tB\t'
+ comptest $'tst NO_List\t__\tB\t'
 0:Documentation example for options, input "NO_List\t__\tB\t"
 >line: {tst NO_List}{}
 >COMPADD:{}
@@ -176,7 +173,7 @@
 >COMPADD:{}
 
  test_code $options_matcher example1_list
- comptest -c "$code" $'tst __\tN\t__o\t___\tlist_\tbeep__\t'
+ comptest $'tst __\tN\t__o\t___\tlist_\tbeep__\t'
 0:Documentation example for options, input "__\tN\t__o\t___\tlist_\tbeep__\t" 
 >line: {tst __}{}
 >COMPADD:{}
@@ -204,7 +201,7 @@
 >COMPADD:{}
 
  test_code $options_matcher example1_list
- comptest -c "$code" $'tst __\tNo\t___\tlist_\tbeep__\t'
+ comptest $'tst __\tNo\t___\tlist_\tbeep__\t'
 0:Documentation example for options, input "__\tNo\t___\tlist_\tbeep__\t" 
 >line: {tst __}{}
 >COMPADD:{}
@@ -231,7 +228,7 @@
 
 
  test_code $options_matcher example1_list
- comptest -c "$code" $'tst ___\tlist_\tbeep__\t'
+ comptest $'tst ___\tlist_\tbeep__\t'
 0:Documentation example for options, input "___\tlist_\tbeep__\t" 
 >line: {tst ___}{}
 >COMPADD:{}
@@ -261,7 +258,7 @@
  lower_insensitive_m="m:{a-z}={A-Z}"
  example2_list=(ABC Abc abc)
  test_code $lower_insensitive_M example2_list
- comptest -c "$code" $'tst ab\tC\t'
+ comptest $'tst ab\tC\t'
 0:Documentation example for lowercase insenitive M, input "ab\tC\t"
 >line: {tst ab}{}
 >COMPADD:{}
@@ -271,7 +268,7 @@
 >COMPADD:{}
 
  test_code $lower_insensitive_m example2_list
- comptest -c "$code" $'tst A\t\t'
+ comptest $'tst A\t\t'
 0:Documentation example for lowercase insenitive m, input "A\t\t" 
 >line: {tst A}{}
 >COMPADD:{}
@@ -284,7 +281,7 @@
  case_insensitive_M="M:{a-zA-Z}={A-Za-z}"
  case_insensitive_m="m:{a-zA-Z}={A-Za-z}"
  test_code $case_insensitive_M example3_list
- comptest -c "$code" $'tst aB\t\t'
+ comptest $'tst aB\t\t'
 0:Documentation example for case insenitive M, input "aB\t\t"
 >line: {tst aB}{}
 >COMPADD:{}
@@ -295,7 +292,7 @@
 
 
  test_code $case_insensitive_m example3_list
- comptest -c "$code" $'tst aB\t\t'
+ comptest $'tst aB\t\t'
 0:Documentation example for case insenitive m, input "aB\t\t"
 >line: {tst a}{BC}
 >COMPADD:{}
@@ -317,13 +314,13 @@
   comp.graphics.rendering.misc comp.graphics.rendering.raytracing
   comp.graphics.rendering.renderman)
  test_code $example4_matcher example4_list
- comptest -c "$code" $'tst c.s.u\t'
+ comptest $'tst c.s.u\t'
 0:Documentation example using input c.s.u
 >line: {tst comp.sources.unix }{}
 >COMPADD:{}
 
  test_code $example4_matcher example4_list
- comptest -c "$code" $'tst c.g.\ta\t.\tp\ta\tg\t'
+ comptest $'tst c.g.\ta\t.\tp\ta\tg\t'
 0:Documentation example using input c.g.\ta\t.\tp\ta\tg\t
 >line: {tst comp.graphics.}{}
 >COMPADD:{}
@@ -357,13 +354,13 @@
 >COMPADD:{}
 
  test_code $example4_matcher example4_list
- comptest -c "$code" $'tst c...pag\t'
+ comptest $'tst c...pag\t'
 0:Documentation example using input c...pag\t
 >line: {tst comp.graphics.apps.pagemaker }{}
 >COMPADD:{}
 
  test_code $example4_matcher example4_list
- comptest -c "$code" $'tst c...pa\tg\t'
+ comptest $'tst c...pa\tg\t'
 0:Documentation example using input c...pa\tg\t
 >line: {tst comp.graphics.apps.pa}{}
 >COMPADD:{}
@@ -373,7 +370,7 @@
  example5_matcher='r:|[.,_-]=* r:|=*'
  example5_list=(veryverylongfile.c veryverylongheader.h)
  test_code $example5_matcher example5_list
- comptest -c "$code" $'tst  v.c\tv.h\t'
+ comptest $'tst  v.c\tv.h\t'
 0:Documentation example using input v.c\t
 >line: {tst  veryverylongfile.c }{}
 >COMPADD:{}
@@ -383,19 +380,19 @@
 
  example6_list=(LikeTHIS FooHoo 5foo123 5bar234)
  test_code 'r:|[A-Z0-9]=* r:|=*' example6_list
- comptest -c "$code" $'tst H\t'
+ comptest $'tst H\t'
 0:Documentation example using "r:|[A-Z0-9]=* r:|=*", input H
 >line: {tst H}{}
 >COMPADD:{}
 
  test_code 'r:|[A-Z0-9]=* r:|=*' example6_list
- comptest -c "$code" $'tst 2\t'
+ comptest $'tst 2\t'
 0:Documentation example using "r:|[A-Z0-9]=* r:|=*", input 2
 >line: {tst 2}{}
 >COMPADD:{}
 
  test_code 'r:|[A-Z0-9]=** r:|=*' example6_list
- comptest -c "$code" $'tst H\t'
+ comptest $'tst H\t'
 0:Documentation example using "r:|[A-Z0-9]=* r:|=*", input 2
 >line: {tst H}{}
 >COMPADD:{}
@@ -403,7 +400,7 @@
 >NO:{LikeTHIS}
 
  test_code 'r:|[A-Z0-9]=** r:|=*' example6_list
- comptest -c "$code" $'tst 2\t\t'
+ comptest $'tst 2\t\t'
 0:Documentation example using "r:|[A-Z0-9]=* r:|=*", input 2
 >line: {tst 523}{}
 >COMPADD:{}
@@ -415,7 +412,7 @@
  example7_matcher="r:[^A-Z0-9]||[A-Z0-9]=** r:|=*"
  example7_list=($example6_list)
  test_code $example7_matcher example7_list
- comptest -c "$code" $'tst H\t2\t'
+ comptest $'tst H\t2\t'
 0:Documentation example using "r:[^A-Z0-9]||[A-Z0-9]=** r:|=*"
 >line: {tst FooHoo }{}
 >COMPADD:{}
@@ -426,13 +423,13 @@
  workers_7311_matcher="m:{a-z}={A-Z} r:|[.,_-]=* r:|=*"
  workers_7311_list=(Abc-Def-Ghij.txt Abc-def.ghi.jkl_mno.pqr.txt Abc_def_ghi_jkl_mno_pqr.txt)
  test_code $workers_7311_matcher workers_7311_list
- comptest -c "$code" $'tst a-a\t'
+ comptest $'tst a-a\t'
 0:Bug from workers 7311
 >line: {tst a-a}{}
 >COMPADD:{}
 
  test_code $workers_7311_matcher workers_7311_list
- comptest -c "$code" $'tst a\t\t-d.\t'
+ comptest $'tst a\t\t-d.\t'
 0:Bug from workers_7311 
 >line: {tst Abc}{}
 >COMPADD:{}
@@ -447,7 +444,7 @@
  workers_10886_matcher="r:|[A-Z0-9]=* r:|=*"
  workers_10886_list=(BW UWB W)
  test_code $workers_10886_matcher workers_10886_list
- comptest -c "$code" $'tst W\t'
+ comptest $'tst W\t'
 0:Bug from workers 10886
 >line: {tst W }{}
 >COMPADD:{}
@@ -455,7 +452,7 @@
  workers_11081_matcher='m:{a-zA-Z}={A-Za-z} r:|[.,_-]=* r:[^A-Z0-9]||[A-Z0-9]=* r:[A-Z0-9]||[^A-Z0-9]=* r:[^0-9]||[0-9]=* r:|=*'
  workers_11081_list=(build.out build.out1 build.out2)
  test_code $workers_11081_matcher workers_11081_list
- comptest -c "$code" $'tst bui\t\t\t'
+ comptest $'tst bui\t\t\t'
 0:Bug from workers 11081
 >line: {tst build.out}{}
 >COMPADD:{}
@@ -471,7 +468,7 @@
  workers_11388_matcher='r:|[:.]=* r:|=*'
  workers_11388_list=(a.b:0 c.d:1)
  test_code $workers_11388_matcher workers_11388_list
- comptest -c "$code" $'tst :\t'
+ comptest $'tst :\t'
 0:Non-bug from workers 11388
 >line: {tst :}{}
 >COMPADD:{}
@@ -479,7 +476,7 @@
  workers_11388_matcher='r:|[:.]=** r:|=*'
  workers_11388_list=(a.b:0 c.d:1)
  test_code $workers_11388_matcher workers_11388_list
- comptest -c "$code" $'tst :\t'
+ comptest $'tst :\t'
 0:Non-bug from workers 11388
 >line: {tst }{.:}
 >COMPADD:{}
-- 
Tanaka Akira


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

* Re: PATCH: Completion matching control test. (Try 2)
@ 2000-05-17 10:33 Sven Wischnowsky
  2000-05-17 12:30 ` Tanaka Akira
  0 siblings, 1 reply; 9+ messages in thread
From: Sven Wischnowsky @ 2000-05-17 10:33 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On May 16,  9:11pm, Felix Rosencrantz wrote:
> } Subject: Re: PATCH: Completion matching control test. (Try 2)
> }
> } --- Bart Schaefer <schaefer@candle.brasslantern.com> wrote:
> } > This works for me:
> } > 
> } > 	print -lr "COMPADD:{${match[6]//[$'\r\n']/}}"
> } 
> } Great. Works for me, too.  Will use that.  I'll send a patch when the
> } changes make it into the repository.
> 
> Hrm, OK, but based on PWS's last comment I'm hesitant to commit what I
> have.  (I also deleted a stray `debug=yes' from comptest.)
> 
> Sven, Peter?  Do we want this test in there now, or not?

I'm working on it and will commit it when I'm finished, which may take 
some time because those tests are so damn slow. I wished there were a
way to make comptest initialise the completion system only once.

> } > I suspect the other failed tests are confusion over `*' vs. `**' in the
> } > matcher patterns, but I'm not sure.  For example, the test
> } 
> } Drat, I don't have any tests that use the double star syntax...
> 
> Definitely either your tests are wrong, or the examples in the doc are
> wrong, in several instances.  And I'm unsure about the cursor placement
> differences that I mentioned; e.g. I'm not sure your H\t2\t test would
> work because the 2 might not be inserted in the same place as before.

The docs are wrong, I've fixed that and will send it together with the 
rest.

Bye
 Sven


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


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

* Re: PATCH: Completion matching control test. (Try 2)
  2000-05-17  4:11 Felix Rosencrantz
@ 2000-05-17 10:14 ` Bart Schaefer
  0 siblings, 0 replies; 9+ messages in thread
From: Bart Schaefer @ 2000-05-17 10:14 UTC (permalink / raw)
  To: Felix Rosencrantz, zsh-workers

On May 16,  9:11pm, Felix Rosencrantz wrote:
} Subject: Re: PATCH: Completion matching control test. (Try 2)
}
} --- Bart Schaefer <schaefer@candle.brasslantern.com> wrote:
} > This works for me:
} > 
} > 	print -lr "COMPADD:{${match[6]//[$'\r\n']/}}"
} 
} Great. Works for me, too.  Will use that.  I'll send a patch when the
} changes make it into the repository.

Hrm, OK, but based on PWS's last comment I'm hesitant to commit what I
have.  (I also deleted a stray `debug=yes' from comptest.)

Sven, Peter?  Do we want this test in there now, or not?
 
} > I suspect the other failed tests are confusion over `*' vs. `**' in the
} > matcher patterns, but I'm not sure.  For example, the test
} 
} Drat, I don't have any tests that use the double star syntax...

Definitely either your tests are wrong, or the examples in the doc are
wrong, in several instances.  And I'm unsure about the cursor placement
differences that I mentioned; e.g. I'm not sure your H\t2\t test would
work because the 2 might not be inserted in the same place as before.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: PATCH: Completion matching control test. (Try 2)
@ 2000-05-17  4:11 Felix Rosencrantz
  2000-05-17 10:14 ` Bart Schaefer
  0 siblings, 1 reply; 9+ messages in thread
From: Felix Rosencrantz @ 2000-05-17  4:11 UTC (permalink / raw)
  To: zsh-workers

--- Bart Schaefer <schaefer@candle.brasslantern.com> wrote:
> This works for me:
> 
> 	print -lr "COMPADD:{${match[6]//[$'\r\n']/}}"
> 
> Normally $'...' isn't expanded inside double quotes, but because it's
> inside an embedded ${...} expansion, the rules get bent.

Great. Works for me, too.  Will use that.  I'll send a patch when the changes
make it into the repository.  I don't think there is a need for try 3.
 
> I suspect the other failed tests are confusion over `*' vs. `**' in the
> matcher patterns, but I'm not sure.  For example, the test

Drat, I don't have any tests that use the double star syntax...

I used several recent versions of zsh to create the output for the tests, plus
a little hand-editing.  Sven's changes have fixed some problems, that I might
have left in, because I'm unclear on what the proper result should be.  Like
the problem report from workers/11388.

Hopefully the test will help.  I think matching control is great.

-FR.



__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/


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

* Re: PATCH: Completion matching control test. (Try 2)
  2000-05-16  6:04 Felix Rosencrantz
  2000-05-16  8:55 ` Peter Stephenson
@ 2000-05-16 17:23 ` Bart Schaefer
  1 sibling, 0 replies; 9+ messages in thread
From: Bart Schaefer @ 2000-05-16 17:23 UTC (permalink / raw)
  To: Felix Rosencrantz, zsh-workers

On May 15, 11:04pm, Felix Rosencrantz wrote:
} Subject: PATCH: Completion matching control test. (Try 2)
}
} I would really like to say
}         print -lr "COMPADD:{${match[6]//[\r\n]/}}"
} 
} But we can't use the backslash escape sequences here.

This works for me:

	print -lr "COMPADD:{${match[6]//[$'\r\n']/}}"

Normally $'...' isn't expanded inside double quotes, but because it's
inside an embedded ${...} expansion, the rules get bent.

(I hope that's not a bug.)

} I'd like to see this added even though the test fails.

The failure included below looks like a bug in the matcher code, because
the L spec should cause the string on the line to be retained.  Several
more tests fail for the same reason (I commented out the cleanup/exit in
ZTST_testfailed to force it to run them all).

I suspect the other failed tests are confusion over `*' vs. `**' in the
matcher patterns, but I'm not sure.  For example, the test

Documentation example using "r:|[A-Z0-9]=* r:|=*", input H

works if I change the * to **, and the "input 2" test after it also gives
the right output with ** but fails based on the ending cursor position.

(Does that mean the examples in the doc are out of date?  I haven't looked
yet.)

*** /tmp/zsh.ztst.out.26952     Tue May 16 09:36:58 2000
--- /tmp/zsh.ztst.tout.26952    Tue May 16 09:37:00 2000
***************
*** 1,2 ****
! line: {tst nolistbeep }{}
  COMPADD:{}
--- 1,2 ----
! line: {tst listbeep }{}
  COMPADD:{}
Test ../../zsh-3.1.6/Test/54compmatch.ztst failed: output differs from expected as shown above for:
  example1_list=(
        kshoptionprint        shglob              
        listambiguous         shinstdin           
        listbeep              shnullcmd           
        listpacked            shoptionletters     
        listrowsfirst         shortloops          
        listtypes             shwordsplit
   )
 options_matcher='L:|[nN][oO]= M:_= M:{A-Z}={a-z}'
 test_code $options_matcher example1_list
 comptest -c "$code" $'tst nolistbee\t'
Was testing: Documentation example for options, input "nolistbee"
../../zsh-3.1.6/Test/54compmatch.ztst: test failed.


-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: PATCH: Completion matching control test. (Try 2)
  2000-05-16  6:04 Felix Rosencrantz
@ 2000-05-16  8:55 ` Peter Stephenson
  2000-05-16 17:23 ` Bart Schaefer
  1 sibling, 0 replies; 9+ messages in thread
From: Peter Stephenson @ 2000-05-16  8:55 UTC (permalink / raw)
  To: Zsh hackers list

> Here is another attempt at posting the matching test.

I haven't added this myself, since it's going to be Sven that resolves any
changes.  It can be held over if necessary --- there's no point in sending
out tests in a distribution if they're going to produce failures we already
know about, which just creates (shudder) moral pressure.

3.1.7-pre-4 has been pushed back 1) because it takes hours to go through
all of compsys.yo 2) because of all the small but important fixes to things
like menu selection 3) because, unfortunately, I'm not going on holiday in
the near future.


By the way here's a minor fix and addition to the octalzeroes manual entry
which I can't be bothered to post separately.

Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.5
diff -u -r1.5 options.yo
--- Doc/Zsh/options.yo	2000/05/15 18:48:21	1.5
+++ Doc/Zsh/options.yo	2000/05/16 08:50:42
@@ -780,8 +780,10 @@
 pindex(OCTAL_ZEROES)
 cindex(octal, arithmetic expressions)
 item(tt(OCTAL_ZEROES) <S>)(
-Interpret any integer constant beginning with a 0 and not
-as octal, per IEEE Std 1003.2-1992 (ISO 9945-2:1993).
+Interpret any integer constant beginning with a 0 as octal, per IEEE Std
+1003.2-1992 (ISO 9945-2:1993).  This is not enabled by default as it
+causes problems with parsing of, for example, date and time strings with
+leading zeroes.
 )
 pindex(OVERSTRIKE)
 cindex(editor, overstrike mode)

-- 
Peter Stephenson <pws@cambridgesiliconradio.com>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


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

* PATCH: Completion matching control test. (Try 2)
@ 2000-05-16  6:04 Felix Rosencrantz
  2000-05-16  8:55 ` Peter Stephenson
  2000-05-16 17:23 ` Bart Schaefer
  0 siblings, 2 replies; 9+ messages in thread
From: Felix Rosencrantz @ 2000-05-16  6:04 UTC (permalink / raw)
  To: zsh-workers

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

Here is another attempt at posting the matching test.

I think the problem that Bart saw in workers/11339 was related to the changes
made to comptest.  I'm guessing the patch didn't get through properly.
The change around line 118 looked something like:
        print -lr "COMPADD:{${match[6]//[^M
]/}}"

I would really like to say
        print -lr "COMPADD:{${match[6]//[\r\n]/}}"

But we can't use the backslash escape sequences here.  My changes to comptest
cause the unfiltered compadd output to contain linefeeds and carriage returns,
which I wanted to filter away.  Is there a better way to do this than putting
the actual control characters in the pattern?

Based on the problem Bart had, I decided to try filtering this whitespace with
the "tr" command.

I've added the bug that Tanaka Akira sent from workers/11388.

I'd like to see this added even though the test fails.  Some failures
are the test, some are the code.  When we have a runnable copy of the
test the appropriate part can be fixed.

This patch supersedes workers/11334.

-FR.

__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 15419 bytes --]

Index: Test/comptest
===================================================================
--- zsh/Test/comptest.orig	Mon May 15 23:00:41 2000
+++ zsh/Test/comptest	Mon May 15 12:00:33 2000
@@ -13,6 +13,7 @@
 zsh=${ZSH:-zsh}
 termcap_ce="$(echotc ce)"
 
+debug=yes
 while getopts Dd:c:z: opt; do
   case $opt in
     D) debug=yes;;
@@ -104,7 +105,7 @@
   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
+  while (( ${(N)log#*(#b)(<LC><(??)><RC>(*)<EC>|<DESCRIPTION>(*)</DESCRIPTION>|<MESSAGE>(*)</MESSAGE>|<COMPADD>(*)</COMPADD>)} )); do
     log="${log[$mend[1]+1,-1]}"
     if (( 0 <= $mbegin[2] )); then
       if [[ $match[2] != TC && $match[3] != \ # ]]; then
@@ -114,6 +115,9 @@
       print -lr "DESCRIPTION:{$match[4]}"
     elif (( 0 <= $mbegin[5] )); then
       print -lr "MESSAGE:{$match[5]}"
+    elif (( 0 <= $mbegin[6] )); then
+      result=`echo $match[6] | tr -d '\012\015'`
+      print -lr "COMPADD:{$result}"
     fi
   done
 done
Index: Test/54compmatch.ztst
===================================================================
--- /dev/null	Mon May 15 22:10:33 2000
+++ zsh/Test/54compmatch.ztst	Mon May 15 22:58:27 2000
@@ -0,0 +1,500 @@
+# Tests for completion system matching control
+
+#Most test follow this format:
+#	test_code $matcher_string selection_list
+#	comptest -c "$code" $' tst input_string'
+# test_code generates the string $codem which sets what words the completion
+# should be selecting from.  The "comnptest function actually performs the
+# completion test, using the completion function generated by test_code.
+#
+# This test also tests error conditions that compadd reports, so output also
+# contains the compadd output.
+
+%prep
+  zmodload -i zsh/zpty
+
+  TERM=vt100
+  export ZTST_testdir ZTST_srcdir TERM
+  comptest () { $ZTST_testdir/../Src/zsh -f $ZTST_srcdir/comptest -z $ZTST_testdir/../Src/zsh -d $ZTST_testdir/compdump.tmp "$@" }
+
+  mkdir match.tmp
+  cd match.tmp
+
+
+  list1=(IndianRed IndianRed2 IndianRed3 IndianRed4)
+  test_code () {
+	matcher=$1;
+	list=$2;
+	code="compdef _tst tst ; _tst () { echo -n '<COMPADD>';compadd -M '"
+	code="$code$matcher"
+	code="$code'  - ${(P)list} ; echo  -n '</COMPADD>'}"
+  }
+
+	 
+
+%test
+
+ test_code z: list1
+ comptest  -c "$code" $'tst \t'
+0:Match Error for "z:"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: unknown match specification character `z'}
+
+ test_code m: list1
+ comptest  -c "$code" $'tst \t'
+0:Match Error for "m:"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: missing patterns}
+
+ test_code M: list1
+ comptest -c "$code" $'tst \t'
+0:Match Error for "M:"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: missing patterns}
+
+ test_code r: list1
+ comptest -c "$code" $'tst \t'
+0:Match Error "r:"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: missing patterns}
+
+ test_code R: list1
+ comptest -c "$code" $'tst \t'
+0:Match Error "R:"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: missing patterns}
+
+ test_code l: list1
+ comptest -c "$code" $'tst \t'
+0:Match Error for "l:"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: missing patterns}
+
+ test_code L: list1
+ comptest -c "$code" $'tst \t'
+0:Match Error for "L:"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: missing patterns}
+
+ test_code 'm:{0-9' list1
+ comptest -c "$code" $'tst \t'
+0:Match Error for "m:{0-9"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: unterminated character class}
+
+ test_code 'm:{0-9}' list1
+ comptest -c "$code" $'tst \t'
+0:Match Error for "m:{0-9}"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: missing word pattern}
+
+ test_code 'm:{0-9}={' list1
+ comptest -c "$code" $'tst \t'
+0:Match Error for "m:{0-9}={"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: unterminated character class}
+
+ test_code 'm:{0-9}={0-' list1
+ comptest -c "$code" $'tst \t'
+0:Match Error for "m:{0-9}={0-"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: unterminated character class}
+
+ test_code 'm:{0-9}={-' list1
+ comptest -c "$code" $'tst \t'
+0:Match Error for "m:{0-9}={-"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: unterminated character class}
+
+ test_code r: list1
+ comptest -c "$code" $'tst \t'
+0:Match Error "r:"
+>line: {tst }{}
+>COMPADD:{_tst:compadd: missing patterns}
+
+  example1_list=(
+	kshoptionprint        shglob              
+	listambiguous         shinstdin           
+	listbeep              shnullcmd           
+	listpacked            shoptionletters     
+	listrowsfirst         shortloops          
+	listtypes             shwordsplit
+   )
+ options_matcher='L:|[nN][oO]= M:_= M:{A-Z}={a-z}'
+ test_code $options_matcher example1_list
+ comptest -c "$code" $'tst nolistbee\t'
+0:Documentation example for options, input "nolistbee"
+>line: {tst nolistbeep }{}
+>COMPADD:{}
+
+
+ test_code $options_matcher example1_list
+ comptest -c "$code" $'tst list_bee\t'
+0:Documentation example for options, input "list_bee"
+>line: {tst list_beep }{}
+>COMPADD:{}
+
+ test_code $options_matcher example1_list
+ comptest -c "$code" $'tst ListBee\t'
+0:Documentation example for options, input "ListBee"
+>line: {tst ListBeep }{}
+>COMPADD:{}
+
+ test_code $options_matcher example1_list
+ comptest -c "$code" $'tst NOList\tB\t'
+0:Documentation example for options, input "NOList"
+>line: {tst NOList}{}
+>COMPADD:{}
+>NO:{NOListambiguous}
+>NO:{NOListbeep}
+>NO:{NOListpacked}
+>NO:{NOListrowsfirst}
+>NO:{NOListtypes}
+>line: {tst NOListBeep }{}
+>COMPADD:{}
+
+
+ test_code $options_matcher example1_list
+ comptest -c "$code" $'tst NO_List\t__\tB\t'
+0:Documentation example for options, input "NO_List\t__\tB\t"
+>line: {tst NO_List}{}
+>COMPADD:{}
+>NO:{NO_Listambiguous}
+>NO:{NO_Listbeep}
+>NO:{NO_Listpacked}
+>NO:{NO_Listrowsfirst}
+>NO:{NO_Listtypes}
+>line: {tst NO_List__}{}
+>COMPADD:{}
+>NO:{NO_List__ambiguous}
+>NO:{NO_List__beep}
+>NO:{NO_List__packed}
+>NO:{NO_List__rowsfirst}
+>NO:{NO_List__types}
+>line: {tst NO_List__Beep }{}
+>COMPADD:{}
+
+ test_code $options_matcher example1_list
+ comptest -c "$code" $'tst __\tN\t__o\t___\tlist_\tbeep__\t'
+0:Documentation example for options, input "__\tN\t__o\t___\tlist_\tbeep__\t" 
+>line: {tst __}{}
+>COMPADD:{}
+>NO:{__kshoptionprint}
+>NO:{__listambiguous}
+>NO:{__listbeep}
+>NO:{__listpacked}
+>NO:{__listrowsfirst}
+>NO:{__listtypes}
+>NO:{__shglob}
+>NO:{__shinstdin}
+>NO:{__shnullcmd}
+>NO:{__shoptionletters}
+>NO:{__shortloops}
+>NO:{__shwordsplit}
+>line: {tst __N}{}
+>COMPADD:{}
+>line: {tst __N__o}{}
+>COMPADD:{}
+>line: {tst __N__o___}{}
+>COMPADD:{}
+>line: {tst __N__o___list_}{}
+>COMPADD:{}
+>line: {tst __N__o___list_beep__}{}
+>COMPADD:{}
+
+ test_code $options_matcher example1_list
+ comptest -c "$code" $'tst __\tNo\t___\tlist_\tbeep__\t'
+0:Documentation example for options, input "__\tNo\t___\tlist_\tbeep__\t" 
+>line: {tst __}{}
+>COMPADD:{}
+>NO:{__kshoptionprint}
+>NO:{__listambiguous}
+>NO:{__listbeep}
+>NO:{__listpacked}
+>NO:{__listrowsfirst}
+>NO:{__listtypes}
+>NO:{__shglob}
+>NO:{__shinstdin}
+>NO:{__shnullcmd}
+>NO:{__shoptionletters}
+>NO:{__shortloops}
+>NO:{__shwordsplit}
+>line: {tst __No}{}
+>COMPADD:{}
+>NO:{__Nokshoptionprint}
+>NO:{__Nolistambiguous}
+>NO:{__Nolistbeep}
+>NO:{__Nolistpacked}
+>NO:{__Nolistrowsfirst}
+>NO:{__Nolisttypes}
+>NO:{__Noshglob}
+>NO:{__Noshinstdin}
+>NO:{__Noshnullcmd}
+>NO:{__Noshoptionletters}
+>NO:{__Noshortloops}
+>NO:{__Noshwordsplit}
+>line: {tst __No___}{}
+>COMPADD:{}
+>NO:{__No___kshoptionprint}
+>NO:{__No___listambiguous}
+>NO:{__No___listbeep}
+>NO:{__No___listpacked}
+>NO:{__No___listrowsfirst}
+>NO:{__No___listtypes}
+>NO:{__No___shglob}
+>NO:{__No___shinstdin}
+>NO:{__No___shnullcmd}
+>NO:{__No___shoptionletters}
+>NO:{__No___shortloops}
+>NO:{__No___shwordsplit}
+>line: {tst __No___list_}{}
+>COMPADD:{}
+>NO:{__No___list_ambiguous}
+>NO:{__No___list_beep}
+>NO:{__No___list_packed}
+>NO:{__No___list_rowsfirst}
+>NO:{__No___list_types}
+>line: {tst __No___list_beep__ }{}
+>COMPADD:{}
+
+
+ test_code $options_matcher example1_list
+ comptest -c "$code" $'tst ___\tlist_\tbeep__\t'
+0:Documentation example for options, input "___\tlist_\tbeep__\t" 
+>line: {tst ___}{}
+>COMPADD:{}
+>NO:{___kshoptionprint}
+>NO:{___listambiguous}
+>NO:{___listbeep}
+>NO:{___listpacked}
+>NO:{___listrowsfirst}
+>NO:{___listtypes}
+>NO:{___shglob}
+>NO:{___shinstdin}
+>NO:{___shnullcmd}
+>NO:{___shoptionletters}
+>NO:{___shortloops}
+>NO:{___shwordsplit}
+>line: {tst ___list_}{}
+>COMPADD:{}
+>NO:{___list_ambiguous}
+>NO:{___list_beep}
+>NO:{___list_packed}
+>NO:{___list_rowsfirst}
+>NO:{___list_types}
+>line: {tst ___list_beep__ }{}
+>COMPADD:{}
+
+ lower_insensitive_M="M:{a-z}={A-Z}"
+ lower_insensitive_m="m:{a-z}={A-Z}"
+ example2_list=(ABC Abc abc)
+ test_code $lower_insensitive_M example2_list
+ comptest -c "$code" $'tst ab\tC\t'
+0:Documentation example for lowercase insenitive M, input "ab\tC\t"
+>line: {tst ab}{}
+>COMPADD:{}
+>NO:{abC}
+>NO:{abc}
+>line: {tst abC }{}
+>COMPADD:{}
+
+ test_code $lower_insensitive_m example2_list
+ comptest -c "$code" $'tst A\t\t'
+0:Documentation example for lowercase insenitive m, input "A\t\t" 
+>line: {tst A}{}
+>COMPADD:{}
+>NO:{ABC}
+>NO:{Abc}
+>line: {tst ABC}{}
+>COMPADD:{}
+
+ example3_list=(ABC Abc abc)
+ case_insensitive_M="M:{a-zA-Z}={A-Za-z}"
+ case_insensitive_m="m:{a-zA-Z}={A-Za-z}"
+ test_code $case_insensitive_M example3_list
+ comptest -c "$code" $'tst aB\t\t'
+0:Documentation example for case insenitive M, input "aB\t\t"
+>line: {tst aB}{}
+>COMPADD:{}
+>NO:{aBC}
+>NO:{aBc}
+>line: {tst aBC}{}
+>COMPADD:{}
+
+
+ test_code $case_insensitive_m example3_list
+ comptest -c "$code" $'tst aB\t\t'
+0:Documentation example for case insenitive m, input "aB\t\t"
+>line: {tst a}{BC}
+>COMPADD:{}
+>line: {tst a}{BC}
+>COMPADD:{}
+>NO:{ABC}
+>NO:{Abc}
+>NO:{abc}
+
+  example4_matcher='r:|.=* r:|=*'
+  example4_list=(comp.sources.unix comp.sources.misc 
+  comp.graphics.algorithms comp.graphics.animation comp.graphics.api
+  comp.graphics.apps comp.graphics.misc comp.graphics.packages
+  comp.graphics.rendering comp.graphics.visualization comp.graphics.apps.alias
+  comp.graphics.apps.gimp comp.graphics.apps.gnuplot
+  comp.graphics.apps.lightwave comp.graphics.apps.pagemaker
+  comp.graphics.apps.paint-shop-pro comp.graphics.apps.photoshop
+  comp.graphics.apps.softimage comp.graphics.apps.ulead
+  comp.graphics.rendering.misc comp.graphics.rendering.raytracing
+  comp.graphics.rendering.renderman)
+ test_code $example4_matcher example4_list
+ comptest -c "$code" $'tst c.s.u\t'
+0:Documentation example using input c.s.u
+>line: {tst comp.sources.unix }{}
+>COMPADD:{}
+
+ test_code $example4_matcher example4_list
+ comptest -c "$code" $'tst c.g.\ta\t.\tp\ta\tg\t'
+0:Documentation example using input c.g.\ta\t.\tp\ta\tg\t
+>line: {tst comp.graphics.}{}
+>COMPADD:{}
+>line: {tst comp.graphics.a}{}
+>COMPADD:{}
+>NO:{comp.graphics.algorithms}
+>NO:{comp.graphics.animation}
+>NO:{comp.graphics.api}
+>NO:{comp.graphics.apps}
+>NO:{comp.graphics.apps.alias}
+>NO:{comp.graphics.apps.gimp}
+>NO:{comp.graphics.apps.gnuplot}
+>NO:{comp.graphics.apps.lightwave}
+>NO:{comp.graphics.apps.pagemaker}
+>NO:{comp.graphics.apps.paint-shop-pro}
+>NO:{comp.graphics.apps.photoshop}
+>NO:{comp.graphics.apps.softimage}
+>NO:{comp.graphics.apps.ulead}
+>line: {tst comp.graphics.apps.}{}
+>COMPADD:{}
+>line: {tst comp.graphics.apps.p}{}
+>COMPADD:{}
+>NO:{comp.graphics.apps.pagemaker}
+>NO:{comp.graphics.apps.paint-shop-pro}
+>NO:{comp.graphics.apps.photoshop}
+>line: {tst comp.graphics.apps.pa}{}
+>COMPADD:{}
+>NO:{comp.graphics.apps.pagemaker}
+>NO:{comp.graphics.apps.paint-shop-pro}
+>line: {tst comp.graphics.apps.pagemaker }{}
+>COMPADD:{}
+
+ test_code $example4_matcher example4_list
+ comptest -c "$code" $'tst c...pag\t'
+0:Documentation example using input c...pag\t
+>line: {tst comp.graphics.apps.pagemaker }{}
+>COMPADD:{}
+
+ test_code $example4_matcher example4_list
+ comptest -c "$code" $'tst c...pa\tg\t'
+0:Documentation example using input c...pa\tg\t
+>line: {tst comp.graphics.apps.pa}{}
+>COMPADD:{}
+>line: {tst comp.graphics.apps.pagemaker }{}
+>COMPADD:{}
+
+ example5_matcher='r:|[.,_-]=* r:|=*'
+ example5_list=(veryverylongfile.c veryverylongheader.h)
+ test_code $example5_matcher example5_list
+ comptest -c "$code" $'tst  v.c\tv.h\t'
+0:Documentation example using input v.c\t
+>line: {tst  veryverylongfile.c }{}
+>COMPADD:{}
+>line: {tst  veryverylongfile.c veryverylongheader.h }{}
+>COMPADD:{}
+
+
+ example6_list=(LikeTHIS FooHoo foo123 bar234)
+ test_code 'r:|[A-Z0-9]=* r:|=*' example6_list
+ comptest -c "$code" $'tst H\t'
+0:Documentation example using "r:|[A-Z0-9]=* r:|=*", input H
+>line: {tst }{H}
+>COMPADD:{}
+>NO:{FooHoo}
+>NO:{LikeTHIS}
+
+ test_code 'r:|[A-Z0-9]=* r:|=*' example6_list
+ comptest -c "$code" $'tst 2\t\t'
+0:Documentation example using "r:|[A-Z0-9]=* r:|=*", input 2
+>line: {tst }{23}
+>COMPADD:{}
+>line: {tst }{23}
+>COMPADD:{}
+>NO:{bar234}
+>NO:{foo123}
+
+ example7_matcher="r:[^A-Z0-9]||[A-Z0-9]=* r:|=*"
+ example7_list=($example6_list)
+ test_code $example7_matcher example7_list
+ comptest -c "$code" $'tst H\t2\t'
+0:Documentation example using "r:[^A-Z0-9]||[A-Z0-9]=* r:|=*"
+>line: {tst FooHoo }{}
+>COMPADD:{}
+>line: {tst FooHoo bar234 }{}
+>COMPADD:{}
+
+
+
+ workers_7311_matcher="m:{a-z}={A-Z} r:|[.,_-]=*"
+ workers_7311_list=(Abc-Def-Ghij.txt Abc-def.ghi.jkl_mno.pqr.txt Abc_def_ghi_jkl_mno_pqr.txt)
+ test_code $workers_7311_matcher workers_7311_list
+ comptest -c "$code" $'tst a-a\t'
+0:Bug from workers 7311
+>line: {tst a-a}{}
+>COMPADD:{}
+
+ test_code $workers_7311_matcher workers_7311_list
+ comptest -c "$code" $'tst a\t\t-d.\t'
+0:Bug from workers_7311 
+>line: {tst Abc}{.txt}
+>COMPADD:{}
+>line: {tst Abc}{.txt}
+>COMPADD:{}
+>NO:{Abc-Def-Ghij.txt}
+>NO:{Abc-def.ghi.jkl_mno.pqr.txt}
+>NO:{Abc_def_ghi_jkl_mno_pqr.txt}
+>line: {tst Abc}{-def.txt}
+>COMPADD:{}
+
+ workers_10886_matcher="r:|[A-Z0-9]=*"
+ workers_10886_list=(BW UWB W)
+ test_code $workers_10886_matcher workers_10886_list
+ comptest -c "$code" $'tst W\t'
+0:Bug from workers 10886
+>line: {tst }{W}
+>COMPADD:{}
+>NO:{BW}
+>NO:{UWB}
+>NO:{W}
+
+ workers_11081_matcher='m:{a-zA-Z}={A-Za-z} r:|[.,_-]=* r:[^A-Z0-9]||[A-Z0-9]=* r:[A-Z0-9]||[^A-Z0-9]=* r:[^0-9]||[0-9]=*'
+ workers_11081_list=(build.out build.out1 build.out2)
+ test_code $workers_11081_matcher workers_11081_list
+ comptest -c "$code" $'tst bui\t\t\t'
+0:Bug from workers 11081
+>line: {tst build.out}{}
+>COMPADD:{}
+>line: {tst build.out}{}
+>COMPADD:{}
+>NO:{build.out}
+>NO:{build.out1}
+>NO:{build.out2}
+>line: {tst build.out}{}
+>COMPADD:{}
+
+
+ workers_11388_matcher='r:|[:.]=* r:|=*'
+ workers_11388_list=(a.b:0 c.d:1)
+ test_code $workers_11388_matcher workers_11388_list
+ comptest -c "$code" $'tst :\t'
+0:Bug from workers 11388
+>line: {tst }{.:}
+>COMPADD:{}
+
+%clean
+exit 0
Index: Test/.distfiles
===================================================================
--- zsh/Test/,.distfiles	Wed Apr 19 12:03:09 2000
+++ zsh/Test/.distfiles	Thu May 11 21:44:19 2000
@@ -5,5 +5,5 @@
     05command.ztst 06arith.ztst 07cond.ztst 08traps.ztst 09funcdef.ztst
     10prompt.ztst 11glob.ztst 12procsubst.ztst 13parameter.ztst
     50cd.ztst 51xtrace.ztst 52zregexparse.ztst
-    53completion.ztst
+    53completion.ztst 54compmatch.ztst
 '

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

end of thread, other threads:[~2000-05-18  2:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-17 11:57 PATCH: Completion matching control test. (Try 2) Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
2000-05-18  2:35 Felix Rosencrantz
2000-05-17 10:33 Sven Wischnowsky
2000-05-17 12:30 ` Tanaka Akira
2000-05-17  4:11 Felix Rosencrantz
2000-05-17 10:14 ` Bart Schaefer
2000-05-16  6:04 Felix Rosencrantz
2000-05-16  8:55 ` Peter Stephenson
2000-05-16 17:23 ` Bart Schaefer

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