From 244f2a14fc2c0b9a57d782a290d17bc1a4299600 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Wed, 26 Mar 2003 17:33:04 +0000 Subject: 18391: add tests for read builtin a few glob qualifiers, 17678 and 18015 --- Test/.distfiles | 2 +- Test/B03print.ztst | 4 ++++ Test/B04read.ztst | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ Test/C01arith.ztst | 4 ++++ Test/D02glob.ztst | 25 +++++++++++++++++++++ 5 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 Test/B04read.ztst (limited to 'Test') diff --git a/Test/.distfiles b/Test/.distfiles index 4a4904085..310744772 100644 --- a/Test/.distfiles +++ b/Test/.distfiles @@ -8,6 +8,6 @@ A03quoting.ztst C04funcdef.ztst Makefile.in ztst.zsh 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 ' diff --git a/Test/B03print.ztst b/Test/B03print.ztst index 4022bc646..f2e12978c 100644 --- a/Test/B03print.ztst +++ b/Test/B03print.ztst @@ -199,3 +199,7 @@ 0:argument specified for precision only >2 >000 + + printf -- '%s\n' str +0:initial `--' ignored to satisfy POSIX +>str diff --git a/Test/B04read.ztst b/Test/B04read.ztst new file mode 100644 index 000000000..45a3486af --- /dev/null +++ b/Test/B04read.ztst @@ -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 + + read -d: <<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 +>hello + + unset REPLY + read -e <<hello +> + + read -e -t <<hello + + SECONDS=0 + read -e -t 5 <<hello +>0 diff --git a/Test/C01arith.ztst b/Test/C01arith.ztst index 0492a20aa..8558d66a8 100644 --- a/Test/C01arith.ztst +++ b/Test/C01arith.ztst @@ -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 diff --git a/Test/D02glob.ztst b/Test/D02glob.ztst index 3a64b8c22..1c8b7acc6 100644 --- a/Test/D02glob.ztst +++ b/Test/D02glob.ztst @@ -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 + -- cgit 1.4.1