#!@SH_PROG@
# -*- shell-script -*-
test_validate_is_function()
{
    _Dbg_is_function
    assertFalse 'No function given; is_function should report false' $?

    unset -f function_test
    _Dbg_is_function function_test
    assertFalse 'function_test should not be defined' "$?"

    typeset -i function_test=1
    _Dbg_is_function function_test
    assertFalse 'test_function should still not be defined' "$?"

    function_test() { :; }
    _Dbg_is_function function_test
    assertTrue 'test_function should now be defined' "$?"

    function another_function_test { :; }
    _Dbg_is_function another_function_test "$?"

    _function_test() { :; }
    _Dbg_is_function _function_test
    assertFalse 'fn _function_test is system fn; is_function should report false' $?

    _Dbg_is_function _function_test 1
    assertTrue 'fn _function_test is system fn which we want; should report true' $?

}

# Test _Dbg_is_int
test_validate_is_integer()
{
    _Dbg_is_int
    assertFalse 'No integer given; is_int should report false' $?

    for arg in a a1 '-+-' ; do
	_Dbg_is_int $arg
	assertFalse "$arg is not an integer; is_int should report false" $?
    done

    for arg in 0 123 9999999 ; do
	_Dbg_is_int $arg
	assertTrue "$arg is an integer; is_int should report true" $?
	_Dbg_is_signed_int $arg
	assertTrue "$arg is a signed integer; is_int should report true" $?
    done

    for arg in +0 -123 ; do
	_Dbg_is_signed_int $arg
	assertTrue "$arg is not a signed integer; is_int should report true" $?
	_Dbg_is_int $arg
	assertFalse "$arg is not an integer; is_int should report true" $?
    done

}

# Make sure @abs_top_srcdir@ has a trailing slash
if [ '@abs_top_srcdir@' = '' ] ; then
  echo "Something is wrong: abs_top_srcdir is not set."
 exit 1
fi
abs_top_srcdir=@abs_top_srcdir@
# Make sure $abs_top_srcdir has a trailing slash
abs_top_srcdir=${abs_top_srcdir%%/}/
. ${abs_top_srcdir}test/unit/helper.sh
. ${abs_top_srcdir}init/vars.sh
. ${abs_top_srcdir}init/pre.sh
. ${abs_top_srcdir}lib/journal.sh
. ${abs_top_srcdir}lib/save-restore.sh
. ${abs_top_srcdir}lib/validate.sh
set -- # reset $# so shunit2 doesn't get confused.

[[ @CMDLINE_INVOKED@ ]] && . ${shunit_file}
