Commits

Anonymous committed 5a8c42f

[svn r533] test on man page

Comments (0)

Files changed (2)

   file3
 
   $ echo /tmp/file1 > /tmp/files
-  $ echo /tmp/file2 > /tmp/files
-  $ echo /tmp/file3 > /tmp/files
+  $ echo /tmp/file2 >> /tmp/files
+  $ echo /tmp/file3 >> /tmp/files
   $ map basename </tmp/files
   file1
   file2
 .SS foldl [-r] EXPRESSION ACC [$ INPUT...]
 Performs a left fold on the input, using \fIEXPRESSION\fP and \fIACC\fP as the starting value. 
 
-For example, you can sum a list of integers using the following left fold:
+For example:
 
-  $ foldl '\\acc x -> echo $(($x + $acc))' 0 $ 1 2 3 4 5
-  15
+  $ define minus = '\\a b -> echo $((a - b))'
+  $ foldl minus 0 $ 1 2 3 4 5
+  -15
+
+Note: \fIfoldl\fP cannot be used to build a lists, i.e. \fIACC\fP must ba a scalar value.
 
 .SS foldr [-r] EXPRESSION ACC [$ INPUT...]
 Performs a right fold on the input, using \fIEXPRESSION\fP and \fIACC\fP as the starting value. 
 
+  $ define minus = '\\a b -> echo $((a - b))'
+  $ foldr minus 0 $ 1 2 3 4 5
+  3
+
+Note: \fIfoldl\fP cannot be used to build a lists, i.e. \fIACC\fP must ba a scalar value.
+
 .SS all EXPRESSION [$ INPUT...]
 
 .SS any EXPRESSION [$ INPUT...]
+#!/bin/bash 
+
+NB_TESTS=0
+
+{
+IN_TEST_CODE=
+IN_TEST_DATA=
+TEST_DATA=
+while read line ; do
+	if echo "$line" | grep -q '^$ ' ; then
+		if [ -z "$IN_TEST_CODE" ] ; then
+			NB_TESTS=$((NB_TESTS + 1))
+			echo
+			echo "function mantest {"
+		fi
+		IN_TEST_CODE=1
+		IN_TEST_DATA=
+		TEST_DATA=
+		line=${line#\$ }
+		echo "  $line"
+	elif [ -n "$line" ] ; then
+		if [ -n "$IN_TEST_CODE" ] ; then
+			echo "}"
+			IN_TEST_CODE=
+			IN_TEST_DATA=1
+		fi
+		if [ -n "$IN_TEST_DATA" ] ; then
+			[ -n "$TEST_DATA" ] && TEST_DATA="$TEST_DATA\\n"
+			TEST_DATA="$TEST_DATA$line"
+		fi
+	else
+		if [ -n "$IN_TEST_DATA" ] ; then
+			TEST_DATA="$TEST_DATA"
+			echo 'is "`mantest`" ' '"`echo -e "'$TEST_DATA'"`"' '"man test #'$NB_TESTS'"'
+		fi
+		IN_TEST_CODE=
+		IN_TEST_DATA=
+	fi
+done < ../bashkell.1
+} > /tmp/mantest.sh
+
+
+source ./test-defs
+source ./tap-functions
+source ../bashkell
+
+
+plan_tests $NB_TESTS
+
+
+source /tmp/mantest.sh