| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# Test of various (well, start with one) function escapes. |
| 4 |
|
| 5 |
set -e |
| 6 |
|
| 7 |
if test -z "${MH_OBJ_DIR}"; then |
| 8 |
srcdir=`dirname "$0"`/../.. |
| 9 |
MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR |
| 10 |
fi |
| 11 |
|
| 12 |
. "$MH_OBJ_DIR/test/common.sh" |
| 13 |
|
| 14 |
setup_test |
| 15 |
expected="$MH_TEST_DIR/test-functions$$.expected" |
| 16 |
actual="$MH_TEST_DIR/test-functions$$.actual" |
| 17 |
|
| 18 |
# check sday when day of week is specified |
| 19 |
start_test "sday when day of week is specified" |
| 20 |
printf '1\n' >"$expected" |
| 21 |
fmttest -raw -format '%(sday{text})' 'Fri Sep 12 20:02 2014' >"$actual" |
| 22 |
check "$expected" "$actual" |
| 23 |
|
| 24 |
# check sday when day of week is not specified |
| 25 |
start_test "sday when day of week is not specified" |
| 26 |
printf '0\n' >"$expected" |
| 27 |
fmttest -raw -format '%(sday{text})' 'Sep 12 20:02 2014' >"$actual" |
| 28 |
check "$expected" "$actual" |
| 29 |
|
| 30 |
# check negative number, without padding |
| 31 |
start_test "negative number, without padding" |
| 32 |
printf '%s\n' ' -42' >"$expected" |
| 33 |
fmttest -raw -format '%4(minus -42)' 0 >"$actual" |
| 34 |
check "$expected" "$actual" |
| 35 |
|
| 36 |
# check negative number, with padding |
| 37 |
start_test "negative number, with padding" |
| 38 |
# Output was "0-42" with nmh 1.6 and earlier. |
| 39 |
printf '%s\n' -042 >"$expected" |
| 40 |
fmttest -raw -format '%04(minus -42)' 0 >"$actual" |
| 41 |
check "$expected" "$actual" |
| 42 |
|
| 43 |
# check multiply |
| 44 |
start_test "multiply" |
| 45 |
printf '%s\n' 42 >"$expected" |
| 46 |
fmttest -raw -format '%(void(num 7))%(multiply 6)' 0 >"$actual" |
| 47 |
check "$expected" "$actual" |
| 48 |
|
| 49 |
finish_test |
| 50 |
exit $failed |