zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: extra loop tests
@ 2003-03-26 14:16 Peter Stephenson
  2003-03-26 17:24 ` bug in read builtin and " Oliver Kiddle
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2003-03-26 14:16 UTC (permalink / raw)
  To: Zsh hackers list

Tests for the enhanced `for' syntax as well as `select' which is now
testable (according to `cvs annotate', I fixed it all of three years ago,
except as we know it was broken for a large fraction of that time
because of the for-loop change.  A year is a short time in zsh
development).

Extra tests gratefully received, as Felix reminded us, particularly for
interactive stuff (zle, completion) which I will not be attempting
myself.

When we finally get the multiple defined limits problem fixed, I will
produce a test version of 4.1.1.  If tests continue to trickle in, so
much the better.

Index: Test/A01grammar.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A01grammar.ztst,v
retrieving revision 1.6
diff -u -r1.6 A01grammar.ztst
--- Test/A01grammar.ztst	17 Sep 2002 10:42:20 -0000	1.6
+++ Test/A01grammar.ztst	26 Mar 2003 14:07:06 -0000
@@ -136,6 +136,29 @@
 >1
 >2
 
+  for keyvar valvar in key1 val1 key2 val2; do
+     print key=$keyvar val=$valvar
+  done
+0:enhanced `for' syntax with two loop variables
+>key=key1 val=val1
+>key=key2 val=val2
+
+  for keyvar valvar stuffvar in keyA valA stuffA keyB valB stuffB; do
+     print key=$keyvar val=$valvar stuff=$stuffvar
+  done
+0:enhanced `for' syntax with three loop variables
+>key=keyA val=valA stuff=stuffA
+>key=keyB val=valB stuff=stuffB
+
+  for in in in in in stop; do
+    print in=$in
+  done
+0:compatibility of enhanced `for' syntax with standard syntax
+>in=in
+>in=in
+>in=in
+>in=stop
+
   name=0
   while (( name < 3 )); do
     print $name
@@ -208,18 +231,17 @@
 >2
 >3
 
-## This doesn't work, because zsh tries to read from the terminal
-## even in a non-interactive shell.  The manual implies it always reads
-## from stdin, even in an interactive shell.
-#  PS3="input> "
-#  select name in one two three; do
-#    print $name
-#  done
-#0:`select' loop
-#<2
-#>1) one     2) two     3) three   
-#>input> 
-#>two
+## Select now reads from stdin if the shell is not interactive.
+## Its own output goes to stderr.
+  PS3="input> "
+  select name in one two three; do
+    print $name
+  done
+0:`select' loop
+<2
+?1) one     2) two     3) three   
+?input> input> 
+>two
 
   function name1 name2 () { print This is $0; }
   name2

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


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

* bug in read builtin and Re: PATCH: extra loop tests
  2003-03-26 14:16 PATCH: extra loop tests Peter Stephenson
@ 2003-03-26 17:24 ` Oliver Kiddle
  2003-03-26 17:52   ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Kiddle @ 2003-03-26 17:24 UTC (permalink / raw)
  To: Zsh hackers list

Peter wrote:
> Tests for the enhanced `for' syntax as well as `select' which is now

I've just added a few tests too. In adding tests for read (to cover the
new read -d), I found that read -t 1 -p causes a seg fault:

#0  0x080bb323 in read_poll (fd=-1, readchar=0xbffff0fc, polltty=0, 
    microseconds=1000000) at utils.c:1398
#1  0x0805eec7 in bin_read (name=0x40020248 "read", args=0xbffff170, 
    ops=0xbffff1b0, func=0) at builtin.c:4215
#2  0x08052545 in execbuiltin (args=0x40020210, bn=0x80cbab4) at builtin.c:440

> Extra tests gratefully received, as Felix reminded us, particularly for
> interactive stuff (zle, completion) which I will not be attempting
> myself.

I've not attempted anything for interactive stuff either I'm afraid.
I've also not done anything for \u or the math locale problem because it
would be dependant on the local environment and the test system sets
LANG=C anyway.

> When we finally get the multiple defined limits problem fixed, I will
> produce a test version of 4.1.1.  If tests continue to trickle in, so
> much the better.

Also one of 17797 or 17820 should be committed before a release. I don't
have access to cygwin so can't test 17820.

There have been enough changes to warrant a 4.0.7 before too long.
Any suggestions on stuff which can be merged back from 4.1?

Oliver

Index: Test/.distfiles
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/.distfiles,v
retrieving revision 1.14
diff -u -r1.14 .distfiles
--- Test/.distfiles	17 Dec 2001 17:17:38 -0000	1.14
+++ Test/.distfiles	26 Mar 2003 17:05:03 -0000
@@ -8,6 +8,6 @@
 A04redirect.ztst     D01prompt.ztst       V02zregexparse.ztst
 A05execution.ztst    D02glob.ztst         Y01completion.ztst
 D06subscript.ztst    V01zmodload.ztst     E01options.ztst
-B02typeset.ztst      B03print.ztst        A06assign.ztst
+B02typeset.ztst      B03print.ztst        A06assign.ztst       B04read.ztst
 README
 '
Index: Test/B03print.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/B03print.ztst,v
retrieving revision 1.5
diff -u -r1.5 B03print.ztst
--- Test/B03print.ztst	27 Aug 2002 21:11:44 -0000	1.5
+++ Test/B03print.ztst	26 Mar 2003 17:05:03 -0000
@@ -199,3 +199,7 @@
 0:argument specified for precision only
 >2
 >000
+
+ printf -- '%s\n' str
+0:initial `--' ignored to satisfy POSIX
+>str
Index: Test/B04read.ztst
===================================================================
RCS file: Test/B04read.ztst
diff -N Test/B04read.ztst
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Test/B04read.ztst	26 Mar 2003 17:05:03 -0000
@@ -0,0 +1,65 @@
+# Tests for the read builtin
+
+# Tested elsewhere:
+#  reading from a coprocess  A01grammar, A04redirect
+
+# Not tested:
+#  -c/-l/-n (options for compctl functions)
+#  -q/-s (needs a tty)
+
+%test
+
+ read <<<'hello world'
+ print $REPLY
+0:basic read command
+>hello world
+
+ read -A <<<'hello world'
+ print $reply[2]
+0:array read
+>world
+
+ read -k3 -u0 <<<foo:bar
+ print $REPLY
+0:read specified number of chars
+>foo
+
+ read -d: <<<foo:bar
+ print $REPLY
+0:read up to delimiter
+>foo
+
+ print foo:bar|IFS=: read -A
+ print $reply
+0:use different, IFS separator to array
+>foo bar
+
+ print -z hello world; read -z
+ print $REPLY
+0:read from editor buffer stack
+>hello world
+
+ unset REPLY
+ read -E <<<hello
+ print $REPLY
+0:read with echoing and assigning
+>hello
+>hello
+
+ unset REPLY
+ read -e <<<hello
+ print $REPLY
+0:read with echoing but assigning disabled
+>hello
+>
+
+ read -e -t <<<hello
+0:read with test first
+>hello
+
+ SECONDS=0
+ read -e -t 5 <<<hello
+ print $SECONDS
+0:read with timeout (no waiting should occur)
+>hello
+>0
Index: Test/C01arith.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/C01arith.ztst,v
retrieving revision 1.5
diff -u -r1.5 C01arith.ztst
--- Test/C01arith.ztst	23 Jan 2002 16:28:17 -0000	1.5
+++ Test/C01arith.ztst	26 Mar 2003 17:05:03 -0000
@@ -98,3 +98,7 @@
   print $x
 0:assigning to scalar which contains non-math string
 >32
+
+  print $(( ))
+0:empty math parse e.g. $(( )) acts like a zero
+>0
Index: Test/D02glob.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D02glob.ztst,v
retrieving revision 1.1
diff -u -r1.1 D02glob.ztst
--- Test/D02glob.ztst	2 Apr 2001 12:33:33 -0000	1.1
+++ Test/D02glob.ztst	26 Mar 2003 17:05:03 -0000
@@ -16,7 +16,7 @@
     setopt nonullglob nomatch
     print glob.tmp/**/*~(.)#
   }
-
+  
 %test
 
   globtest globtests
@@ -265,3 +265,28 @@
 0:exclusions regression test
 >
 >glob.tmp/a glob.tmp/b glob.tmp/c glob.tmp/dir1 glob.tmp/dir1/a glob.tmp/dir1/b glob.tmp/dir1/c glob.tmp/dir2 glob.tmp/dir2/a glob.tmp/dir2/b glob.tmp/dir2/c
+
+ print glob.tmp/*(/)
+0:Just directories
+>glob.tmp/dir1 glob.tmp/dir2
+
+ print glob.tmp/*(.)
+0:Just files
+>glob.tmp/a glob.tmp/b glob.tmp/c
+
+ print glob.tmp/*(.e^'reply=( glob.tmp/*/${REPLY:t} )'^:t)
+0:Globbing used recursively (inside e glob qualifier)
+>a a b b c c
+
+ print glob.tmp/**/(:h) 
+0:Head modifier
+>. glob.tmp glob.tmp
+
+ print glob.tmp(:r)
+0:Remove extension modifier
+>glob
+
+ print glob.tmp/*(:s/./_/)
+0:Substitute modifier
+>glob_tmp/a glob_tmp/b glob_tmp/c glob_tmp/dir1 glob_tmp/dir2
+


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

* Re: bug in read builtin and Re: PATCH: extra loop tests
  2003-03-26 17:24 ` bug in read builtin and " Oliver Kiddle
@ 2003-03-26 17:52   ` Peter Stephenson
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2003-03-26 17:52 UTC (permalink / raw)
  To: Zsh hackers list

Oliver Kiddle wrote:
> In adding tests for read (to cover the
> new read -d), I found that read -t 1 -p causes a seg fault:

I think this test needs to be in other places, but the logic in
bin_read() is a bit tortuous.

Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.97
diff -u -r1.97 builtin.c
--- Src/builtin.c	17 Feb 2003 10:08:03 -0000	1.97
+++ Src/builtin.c	26 Mar 2003 17:50:28 -0000
@@ -4212,7 +4212,8 @@
 		timeout = (zlong)mn.u.l * (zlong)1000000;
 	    }
 	}
-	if (!read_poll(readfd, &readchar, keys && !zleactive, timeout)) {
+	if (readfd == -1 ||
+	    !read_poll(readfd, &readchar, keys && !zleactive, timeout)) {
 	    if (OPT_ISSET(ops,'k') && !zleactive && !isem)
 		settyinfo(&shttyinfo);
 	    if (haso) {

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


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

end of thread, other threads:[~2003-03-26 17:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-26 14:16 PATCH: extra loop tests Peter Stephenson
2003-03-26 17:24 ` bug in read builtin and " Oliver Kiddle
2003-03-26 17:52   ` Peter Stephenson

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