zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
To: zsh-workers@sunsite.auc.dk (Zsh hackers list)
Subject: PATCH: prompt escape tests
Date: Tue, 01 Feb 2000 20:54:06 +0000	[thread overview]
Message-ID: <E12FkGP-00076q-00.2000-02-01-20-51-05@cmailg7.svr.pol.co.uk> (raw)

I've been slow producing more tests.  This is for prompt escapes; there's a
bit in the .distfiles hunk to add Bart's funcdef test to the distribution.

As always, this is not supposed to be exhaustive:  if a particular problem
turns up, it's likely to be in something more complicated than what's been
tested, and will have to be added by hand.

If I remember, there was a failed test reported by Sven to do with
different system behaviour which hasn't been fixed up yet.

One thing that turned up here is that `prompt -P %~' doesn't work in
non-interactive shells, i.e. doesn't do the directory table lookup (or
doesn't even put it into a directory table, I haven't checked).
Whether this is intentional or not, it's not mentioned in the manual.  I
can't see any good reason for it.

Index: Test/.distfiles
===================================================================
RCS file: /home/pws/CVSROOT/projects/zsh/Test/.distfiles,v
retrieving revision 1.4
diff -u -r1.4 .distfiles
--- Test/.distfiles	2000/01/14 12:33:36	1.4
+++ Test/.distfiles	2000/02/01 20:43:58
@@ -2,5 +2,6 @@
     .cvsignore .distfiles Makefile.in
     ztst.zsh
     01grammar.ztst 02alias.ztst 03quoting.ztst 04redirect.ztst
-    05command.ztst 06arith.ztst 07cond.ztst 08traps.ztst 50cd.ztst
+    05command.ztst 06arith.ztst 07cond.ztst 08traps.ztst 09funcdef.ztst
+    10prompt.ztst 50cd.ztst
 '
Index: Test/10prompt.ztst
===================================================================
RCS file: 10prompt.ztst
diff -N 10prompt.ztst
--- /dev/null	Tue May  5 21:32:27 1998
+++ 10prompt.ztst	Tue Feb  1 20:43:33 2000
@@ -0,0 +1,106 @@
+%prep
+
+  mydir=$PWD
+  SHLVL=2
+  setopt extendedglob
+
+%test
+
+# 'mydir=$PWD; hash -d mydir; print -P %~' doesn't seem to abbreviate
+# to ~mydir in a non-interactive shell.  Is this correct?
+
+  print -P '  %%%):  %)
+  %%d:  %d
+  %%1/: %1/
+  %%h:  %h
+  %%L:  %L
+  %%M:  %M
+  %%m:  %m
+  %%n:  %n
+  %%N:  %N
+  %%i:  %i
+  a%%{...%%}b:  a%{%}b
+  '
+0q:Basic prompt escapes as shown.
+>  %):  )
+>  %d:  $mydir
+>  %1/: ${mydir:t}
+>  %h:  0
+>  %L:  2
+>  %M:  $HOST
+>  %m:  ${HOST%%.*}
+>  %n:  $USERNAME
+>  %N:  ZTST_execchunk
+>  %i:  2
+>  a%{...%}b:  ab
+>  
+
+  true
+  print -P '%?'
+  false
+  print -P '%?'
+0:`%?' prompt escape
+>0
+>1
+
+  PS4="%_> "
+  setopt xtrace
+  if true; then true; else false; fi
+  unsetopt xtrace
+0:`%_' prompt escape
+?if> true
+?then> true
+?> unsetopt xtrace
+
+  diff =(print -P '%#') =(print -P '%(!.#.%%)')
+0:`%#' prompt escape and its equivalent
+
+  psvar=(caesar adsum jam forte)
+  print -P '%v' '%4v'
+0:`%v' prompt escape
+>caesar forte
+
+  true
+  print -P '%(?.true.false)'
+  false
+  print -P '%(?.true.false)'
+0:ternary prompt escapes
+>true
+>false
+
+  print -P '%10<...<truncated at 10%<< Not truncated'
+  print -P '%10>...>truncated at 10%>> Not truncated'
+0:prompt truncation
+>...d at 10 Not truncated
+>truncat... Not truncated
+
+# It's hard to check the time and date as they are moving targets.
+# We therefore just check that various forms of the date are consistent.
+# In fact, if you perform this at midnight it can still fail.
+# We could test for that, but we can't be bothered.
+# I hope LC_ALL is enough to make the format what's expected.
+
+  LC_ALL=C
+  date1=$(print -P %w)
+  date2=$(print -P %W)
+  date3=$(print -P %D)
+  if [[ $date1 != [A-Z][a-z][a-z][[:blank:]]##[0-9]## ]]; then
+    print "Date \`$date1' is not in the form \`Day DD' (e.g. \`Mon 1'"
+  fi
+  if [[ $date2 != [0-9][0-9]/[0-9][0-9]/[0-9][0-9] ]]; then
+    print "Date \`$date2' is not in the form \`DD/MM/YYYY'"
+  fi
+  if [[ $date3 != [0-9][0-9]-[0-9][0-9]-[0-9][0-9] ]]; then
+    print "Date \`$date3' is not in the form \`YY-MM-DD'"
+  fi
+  if (( $date1[5,-1] != $date2[4,5] )) || (( $date2[4,5] != $date3[8,9] ))
+  then
+    print "Days of month do not agree in $date1, $date2, $date3"
+  fi
+  if (( $date2[1,2] != $date3[4,5] )); then
+    print "Months do not agree in $date2, $date3"
+  fi
+  if (( $date2[7,8] != $date3[1,2] )); then
+    print "Years do not agree in $date2, $date3"
+  fi
+0:Dates produced by prompt escapes

-- 
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>


             reply	other threads:[~2000-02-01 20:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-01 20:54 Peter Stephenson [this message]
2000-02-02  8:34 Sven Wischnowsky
2000-02-02 16:21 ` Tanaka Akira
2000-02-02 16:51   ` Dan Nelson

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=E12FkGP-00076q-00.2000-02-01-20-51-05@cmailg7.svr.pol.co.uk \
    --to=pws@pwstephenson.fsnet.co.uk \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

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

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

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

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