]> diplodocus.org Git - nmh/blobdiff - test/format/test-fmtdump
Create new mh-format function %(ordinal)
[nmh] / test / format / test-fmtdump
index 73fd14de19d84174583d4b752650ea71b6645e27..eded03624124cf1d2c8a2bcc8509fa396aadf5db 100755 (executable)
@@ -19,6 +19,29 @@ setup_test
 # Use proper program, likely not the first one on PATH.
 fmtdump="${MH_LIBEXEC_DIR}/fmtdump"
 
+check_exit '-eq 1' "$fmtdump" -
+check_exit '-eq 1' "$fmtdump" -form
+check_exit '-eq 1' "$fmtdump" -format
+check_exit '-eq 1' "$fmtdump" foo bar
+check_exit '-eq 0' "$fmtdump" -format '
+    %4{} %(eq) %(getenv) %(decodecomp{}) %(trim{}) %(putaddr)
+    %(putlit) %(zputlit) %(compval{}) %(num)
+    %(plus) %(minus) %(multiply) %(divide) %(modulo)
+    %(charleft) %(kilo) %(kibi)
+    %(month{}) %(tzone{}) %(day{}) %(weekday{}) %(tws{}) %(pretty{})
+    %(sec{}) %(min{}) %(hour{}) %(year{}) %(yday{}) %(wday{})
+    %(clock{}) %(rclock{}) %(sday{}) %(dst{}) %(szone{})
+    %(date2local{}) %(date2gmt{})
+'
+check_exit '-eq 0' "$fmtdump" -format '
+    %(addr{}) %(pers{}) %(mbox{}) %(host{}) %(path{}) %(gname{})
+    %(note{}) %(proper{}) %(type{}) %(ingrp{}) %(nohost{})
+    %(formataddr) %(concataddr) %(getmymbox{}) %(getmyaddr{})
+    %<(null)%> %<(gt)%> %<(match)%> %<(amatch)%>
+    %(null) %(nonnull) %(ne) %(gt) %(match) %(amatch)
+'
+check_exit '-eq 0' "$fmtdump" -format "`printf '\302\010\014\015\011\177'`"
+
 expected=$MH_TEST_DIR/$$.expected
 expected_err=$MH_TEST_DIR/$$.expected_err
 actual=$MH_TEST_DIR/$$.actual
@@ -35,8 +58,9 @@ Usage: fmtdump [switches]
   -help
 EOF
 
-$fmtdump -help >$actual 2>&1
-check $expected $actual
+#### Skip nmh intro text.
+"$fmtdump" -help 2>&1 | sed '/^$/,$d' >"$actual"
+check "$expected" "$actual"
 
 # check -version
 case `$fmtdump -v` in
@@ -61,12 +85,8 @@ L1:  LS_COMP, comp "replied"
        IF_S continue else goto L2
        CHAR '-'
        GOTO L3
-L2:    LS_COMP, comp "encrypted"
-       IF_S continue else goto L4
-       CHAR 'E'
-L3:    GOTO L5
-L4:    CHAR ' '
-L5:    PARSEDATE, c_name "date", c_type <DATE>
+L2:    CHAR ' '
+L3:    PARSEDATE, c_name "date", c_type <DATE>
        LV_MON, c_name "date", c_type <DATE>
        NUMF, width 2, fill '0'
        CHAR '/'
@@ -74,35 +94,35 @@ L5: PARSEDATE, c_name "date", c_type <DATE>
        LV_MDAY, c_name "date", c_type <DATE>
        NUMF, width 2, fill '0'
        LS_COMP, comp "date", c_type <DATE>
-       IF_S continue else goto L6
+       IF_S continue else goto L4
        CHAR ' '
-       GOTO L7
-L6:    CHAR '*'
-L7:    MYMBOX, c_name "from", c_type <ADDR>
+       GOTO L5
+L4:    CHAR '*'
+L5:    MYMBOX, c_name "from", c_type <ADDR>
        LV_COMPFLAG, comp "from", c_type <ADDR>
-       IF_V_NE 0 continue else goto L8
+       IF_V_NE 0 continue else goto L6
        LS_COMP, comp "to", c_type <ADDR>
-       IF_S continue else goto L8
+       IF_S continue else goto L6
        LIT "To:"
        PARSEADDR, c_name "to", c_type <ADDR>
        LS_FRIENDLY, c_name "to", c_type <ADDR>
-       FT_LS_DECODE
+       LS_DECODE
        STRF, width 14, fill ' '
-L8:    IF_V_EQ 0 continue else goto L9
+L6:    IF_V_EQ 0 continue else goto L7
        PARSEADDR, c_name "from", c_type <ADDR>
        LS_FRIENDLY, c_name "from", c_type <ADDR>
-       FT_LS_DECODE
+       LS_DECODE
        STRF, width 17, fill ' '
-L9:    LIT "  "
+L7:    LIT "  "
        LS_COMP, comp "subject"
-       FT_LS_DECODE
+       LS_DECODE
        STR
        LS_COMP, comp "body"
-       IF_S continue else goto L10
+       IF_S continue else goto L8
        LIT "<<"
        COMP, comp "body"
        LIT ">>"
-L10:   CHAR '\n'
+L8:    CHAR '\n'
        DONE
 EOF
 
@@ -122,12 +142,8 @@ L1:        LS_COMP, comp "replied"
        IF_S continue else goto L2
        CHAR '-'
        GOTO L3
-L2:    LS_COMP, comp "encrypted"
-       IF_S continue else goto L4
-       CHAR 'E'
-L3:    GOTO L5
-L4:    CHAR ' '
-L5:    PARSEDATE, c_name "date", c_type <DATE>
+L2:    CHAR ' '
+L3:    PARSEDATE, c_name "date", c_type <DATE>
        LV_MON, c_name "date", c_type <DATE>
        NUMF, width 2, fill '0'
        CHAR '/'
@@ -135,37 +151,37 @@ L5:       PARSEDATE, c_name "date", c_type <DATE>
        LV_MDAY, c_name "date", c_type <DATE>
        NUMF, width 2, fill '0'
        LS_COMP, comp "date", c_type <DATE>
-       IF_S continue else goto L6
+       IF_S continue else goto L4
        CHAR ' '
-       GOTO L7
-L6:    CHAR '*'
-L7:    MYMBOX, c_name "from", c_type <ADDR>
+       GOTO L5
+L4:    CHAR '*'
+L5:    MYMBOX, c_name "from", c_type <ADDR>
        LV_COMPFLAG, comp "from", c_type <ADDR>
-       IF_V_NE 0 continue else goto L8
+       IF_V_NE 0 continue else goto L6
        LS_COMP, comp "to", c_type <ADDR>
-       IF_S continue else goto L8
+       IF_S continue else goto L6
        LIT "To:"
        PARSEADDR, c_name "to", c_type <ADDR>
        LS_FRIENDLY, c_name "to", c_type <ADDR>
-       FT_LS_DECODE
-       
+       LS_DECODE
+       LS_UNQUOTE
        STRF, width 14, fill ' '
-L8:    IF_V_EQ 0 continue else goto L9
+L6:    IF_V_EQ 0 continue else goto L7
        PARSEADDR, c_name "from", c_type <ADDR>
        LS_FRIENDLY, c_name "from", c_type <ADDR>
-       FT_LS_DECODE
-       
+       LS_DECODE
+       LS_UNQUOTE
        STRF, width 17, fill ' '
-L9:    LIT "  "
+L7:    LIT "  "
        LS_COMP, comp "subject"
-       FT_LS_DECODE
+       LS_DECODE
        STR
        LS_COMP, comp "body"
-       IF_S continue else goto L10
+       IF_S continue else goto L8
        LIT "<<"
        COMP, comp "body"
        LIT ">>"
-L10:   CHAR '\n'
+L8:    CHAR '\n'
        DONE
 EOF