diff options
Diffstat (limited to 'Test/V13zformat.ztst')
| -rw-r--r-- | Test/V13zformat.ztst | 123 |
1 files changed, 122 insertions, 1 deletions
diff --git a/Test/V13zformat.ztst b/Test/V13zformat.ztst index 545d5e615..32245b7e2 100644 --- a/Test/V13zformat.ztst +++ b/Test/V13zformat.ztst @@ -93,8 +93,53 @@ zformat REPLY '' zformat REPLY '' x: 1:one of -f -F -a required +?(eval):zformat:1: one of -afF expected +?(eval):zformat:2: one of -afF expected + + zformat -fff REPLY '' + zformat -FFF REPLY '' + zformat -aaa reply . +0:duplicate -f -F -a ignored + + zformat -af REPLY '' + zformat -fF REPLY '' x: +1:more than one of -f -F -a not allowed +?(eval):zformat:1: only one of -afF allowed +?(eval):zformat:2: only one of -afF allowed + + zformat -f + zformat -f REPLY + zformat -F + zformat -F REPLY +1:-f and -F: param and format string required +?(eval):zformat:1: not enough arguments +?(eval):zformat:2: not enough arguments +?(eval):zformat:3: not enough arguments +?(eval):zformat:4: not enough arguments + + zformat -a + zformat -a reply +1:-a: param and separator required ?(eval):zformat:1: not enough arguments -?(eval):zformat:2: invalid argument: REPLY +?(eval):zformat:2: not enough arguments + + zformat -a reply '' a:b && print -rl - $reply +0:-a with empty separator +>ab + + zformat -F REPLY '<%1d>' 'd:é' && print -r - $REPLY + zformat -F REPLY '<%2d>' 'd:é' && print -r - $REPLY + zformat -F REPLY '<%3d>' 'd:é' && print -r - $REPLY + zformat -F REPLY '<%.1d>' 'd:é' && print -r - $REPLY + zformat -F REPLY '<%.2d>' 'd:é' && print -r - $REPLY + zformat -F REPLY '<%.3d>' 'd:é' && print -r - $REPLY +0f:width specifier is multi-byte-aware +><é> +><é > +><é > +><é> +><é> +><é> zformat -F REPLY %B && print -r - $REPLY zformat -F REPLY %3B && print -r - $REPLY @@ -227,3 +272,79 @@ 0:ternary expression returning literal % or ) >% >) + + zformat -qa reply . + zformat -aq reply . +1:-a + -q not allowed +?(eval):zformat:1: -q not allowed with -a +?(eval):zformat:2: -q not allowed with -a + + zformat -Fq REPLY F && print -r - $REPLY + zformat -qF REPLY F && print -r - $REPLY + zformat -FqF REPLY F && print -r - $REPLY + zformat -q1 -F REPLY F && print -r - $REPLY + zformat -q1F REPLY F && print -r - $REPLY + zformat -q-1 -F REPLY F && print -r - $REPLY +1:optional argument to -q +>F +>F +>F +>F +?(eval):zformat:5: bad argument to -q: 1F +?(eval):zformat:6: bad option: -- + +# the spec order in the format string differs from the order in the arguments +# here to make sure we're testing -qn's effects on the latter + for 1 in '' 0 1 2 3; do + zformat -Fq$1 REPLY '%%x %) %. %X %D %d' d:%foo% D:%bar% && print -r - $REPLY + done +0:-q with and without optarg +>%%x ) %. %X %%bar%% %%foo%% +>%%x ) %. %X %bar% %foo% +>%%x ) %. %X %bar% %%foo%% +>%%x ) %. %X %%bar%% %%foo%% +>%%x ) %. %X %%bar%% %%foo%% + + zformat -Fq REPLY '%(x.%%/%d.%%/%D)' x:1 d:%foo% D:%bar% && print -r - $REPLY + zformat -Fq REPLY '%(X.%%/%d.%%/%D)' x:1 d:%foo% D:%bar% && print -r - $REPLY +0:-q with ternary expression +>%%/%%foo%% +>%%/%%bar%% + + zformat -Fq REPLY '<%1d>' d:%foo% && print -r - $REPLY + zformat -Fq REPLY '<%5d>' d:%foo% && print -r - $REPLY + zformat -Fq REPLY '<%6d>' d:%foo% && print -r - $REPLY + zformat -Fq REPLY '<%7d>' d:%foo% && print -r - $REPLY + zformat -Fq REPLY '<%-7d>' d:%foo% && print -r - $REPLY + zformat -Fq REPLY '<%-7d>' d:foo && print -r - $REPLY +0:-q: min-width specifier ignores extra %s +><%%foo%%> +><%%foo%%> +><%%foo%% > +><%%foo%% > +>< %%foo%%> +>< foo> + + zformat -Fq REPLY '%.1d' d:foo && print -r - $REPLY + zformat -Fq REPLY '%.1d' d:%foo% && print -r - $REPLY + zformat -Fq REPLY '%.4d' d:%foo% && print -r - $REPLY + zformat -Fq REPLY '%.5d' d:%foo% && print -r - $REPLY +0:-q: max-width specifier ignores extra %s +>f +>%% +>%%foo +>%%foo%% + + zformat -Fq REPLY '%4(d.t.f) %5(d.t.f) %6(d.t.f)' d:%foo% && print -r - $REPLY + zformat -Fq REPLY '%-6(d.t.f) %-5(d.t.f) %-4(d.t.f)' d:%foo% && print -r - $REPLY +0:-q: ternary width test ignores extra %s +>t f f +>t t f + + zformat -FQ REPLY '%%x %) %. %X %D %d' d:%foo% D:%bar% && print -r - $REPLY + zformat -FQ0 REPLY '%%x %) %. %X %D %d' d:%foo% D:%bar% && print -r - $REPLY + zformat -FQ1 REPLY '%%x %) %. %X %D %d' d:%foo% D:%bar% && print -r - $REPLY +0:-Q, -Q0, -Q1 +>%x ) %. %X %%bar%% %%foo%% +>%x ) %. %X %bar% %foo% +>%x ) %. %X %bar% %%foo%% |
