zsh-workers
 help / color / mirror / code / Atom feed
d8de2bb047417fb8b805a58d92845261d41116e9 blob 1572 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
 
# Test the use of zformat, if the zsh/zutil module is available.

%prep

  if ! zmodload zsh/zutil 2>/dev/null; then
    ZTST_unimplemented="can't load the zsh/zutil module for testing"
  fi

  # Helper function.  Expects a single format using %s and a value for it.
  zformat_and_print_s() {
    zformat -f REPLY "$1" "s:$2"
    print -r - ${(qq)REPLY}
  }

%test

 zformat_and_print_s '%s'   foo
 zformat_and_print_s '%5s'  min
 zformat_and_print_s '%-5s' neg
 zformat_and_print_s '%.5s' max
 zformat_and_print_s '%.5s' truncated
0:basic zformat test
>'foo'
>'min  '
>'  neg'
>'max'
>'trunc'

 # There may be a set of digits either before or after the opening parenthesis.
 zformat_and_print_s 'The answer is "%3(s.yes.no)".' 3
 zformat_and_print_s 'The answer is "%(3s.yes.no)".' 3
 # The test number defaults to zero.
 zformat_and_print_s '%(s.equal.unequal)' -1
 zformat_and_print_s '%(s.equal.unequal)' 0
 zformat_and_print_s '%(s.equal.unequal)' 1
 # Negative numbers are allowed
 # The delimiter is arbitrary
 zformat_and_print_s '%-4(s.minus four.)' -4
 zformat_and_print_s '%(-4s//minus four)' -4
 # The argument is evaluated as a math expression
 zformat_and_print_s '%18(s.math.)' '6*3'
0:basic conditionals test
>'The answer is "yes".'
>'The answer is "yes".'
>'unequal'
>'equal'
>'unequal'
>'minus four'
>''
>'math'

 () {
   zformat -f 1 '%(8n.%(5j.yes.no).no)' 'n:8' 'j:5'
   echo $1
 }
0:nested conditionals test
>yes

 zformat -a argv . foo:lorem ipsum:bar bazbaz '\\esc\:ape'
 print -rl -- "$@"
0:basic -a test
>foo  .lorem
>ipsum.bar
>bazbaz
>\esc:ape
debug log:

solving d8de2bb04 ...
found d8de2bb04 in https://git.vuxu.org/mirror/zsh/

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