From b075920c3109938f9b4a6ec8715031fcc9ee74f6 Mon Sep 17 00:00:00 2001 From: "kate.ward" Date: Sat, 5 Jan 2013 13:57:46 +0000 Subject: added built-in and expr functions to do math --- source/1.0/src/shflags_test_private.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'source/1.0/src/shflags_test_private.sh') diff --git a/source/1.0/src/shflags_test_private.sh b/source/1.0/src/shflags_test_private.sh index f353bb3..7065940 100755 --- a/source/1.0/src/shflags_test_private.sh +++ b/source/1.0/src/shflags_test_private.sh @@ -179,6 +179,33 @@ testValidIntExpr() _testValidInt _flags_validIntExpr } +_testMath() +{ + fx=$1 + + assertEquals 2 `${fx} 1 + 1` + assertEquals 2 `${fx} '1 + 1'` + + assertNotEquals 3 `${fx} 1 + 1` + assertNotEquals 3 `${fx} '1 + 1'` +} + +testMathBuiltin() +{ + # Are we running a shell that can handle a built-in version? The Solaris + # Bourne shell for one does not support what we need. + if [ "${__FLAGS_FX_VALID_INT}" != '_flags_validIntBuiltin' ]; then + echo 'SKIPPED: this shell does not support the necessary builtins' + return + fi + _testMath _flags_mathBuiltin +} + +testMathExpr() +{ + _testMath _flags_mathExpr +} + #------------------------------------------------------------------------------ # suite functions # -- cgit v1.2.3