When doing an if-test on the result of a function which returns a string
[mmh] / test / tests / repl / test-if-str
diff --git a/test/tests/repl/test-if-str b/test/tests/repl/test-if-str
new file mode 100644 (file)
index 0000000..7582a7d
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+######################################################
+#
+# Test that an '%<(function)...' if-construct correctly
+# tests whether 'str' is empty if the function returns
+# a string, and tests 'value' if the function returns
+# an integer.
+#
+######################################################
+
+# create test replgroupcomps
+form=$MH_TEST_DIR/$$.replgroupcomps
+cat > $form <<EOF
+X-STRING: %(num)%(lit)%<(lit FOO) found%| missing%>\n\
+X-NUMBER: %(num)%(lit)%<(num 3) yes%| no%>\n\
+X-NOSTRING: %(num 3)%(lit x)%<(lit) found%| missing%>\n\
+X-NONUMBER: %(num 3)%(lit x)%<(num) yes%| no%>\n\
+--------
+EOF
+
+expected=$MH_TEST_DIR/$$.expected
+actual=$MH_TEST_DIR/Mail/draft
+
+cat > $expected <<EOF
+X-STRING: 0 found
+X-NUMBER: 0 yes
+X-NOSTRING: 3x missing
+X-NONUMBER: 3x no
+--------
+Test1 writes:
+> This is message number 1
+EOF
+
+repl -editor true -format -form $form -group -nocc me -nowhatnowproc 1
+
+diff -u $expected $actual