openenvutils/commandshell/shell/test/scripts/functionstest.sh
changeset 0 2e3d3ce01487
child 1 0fdb7f6b0309
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 # Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 # All rights reserved.
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of the License "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Nokia Corporation - initial contribution.
       
    10 #
       
    11 # Contributors:
       
    12 #
       
    13 # Description:
       
    14 #
       
    15 
       
    16 init()
       
    17     {
       
    18     let totalno=0;
       
    19     let passno=0;
       
    20     let failno=0;
       
    21     }
       
    22 
       
    23 # "functions -m somepattern" to autoload patterned functions
       
    24 test_functions2()
       
    25 {
       
    26 let totalno=totalno+1
       
    27 echo "Test $totalno: autoload with -m somepattern as arguments, to autoload functions with somepattem"
       
    28 functions -m test
       
    29 ret=$?
       
    30 if [ $ret = 0 ]
       
    31 then
       
    32     echo "PASS"
       
    33     let passno=passno+1
       
    34 else
       
    35     echo "FAIL: Expected 0, returned $ret"
       
    36     let failno=failno+1
       
    37 fi
       
    38 }
       
    39 
       
    40 # "functions -mz nonexisingpattern" to autoload patterned functions in zsh mode
       
    41 test_functions3()
       
    42 {
       
    43 let totalno=totalno+1
       
    44 echo "Test $totalno: autoload with -mz nonexistingpattern as arguments, to autoload functions with nonexisting pattem in zsh mode"
       
    45 functions -mz nonexistingpatterm
       
    46 ret=$?
       
    47 if [ $ret = 0 ]
       
    48 then
       
    49     echo "PASS"
       
    50     let passno=passno+1
       
    51 else
       
    52     echo "FAIL: Expected 0, returned $ret"
       
    53     let failno=failno+1
       
    54 fi
       
    55 }
       
    56 
       
    57 util_functions4()
       
    58 {
       
    59 echo hello
       
    60 }
       
    61 
       
    62 # "functions -mz exisingpattern" to autoload patterned functions in zsh mode
       
    63 test_functions4()
       
    64 {
       
    65 let totalno=totalno+1
       
    66 echo "Test $totalno: autoload with -mz existingpattern as arguments, to autoload functions with pattem in zsh mode"
       
    67 util_functions4
       
    68 functions -mz util_functions4
       
    69 ret=$?
       
    70 if [ $ret = 0 ]
       
    71 then
       
    72     echo "PASS"
       
    73     let passno=passno+1
       
    74 else
       
    75     echo "FAIL: Expected 0, returned $ret"
       
    76     let failno=failno+1
       
    77 fi
       
    78 }
       
    79 
       
    80 # "functions -mk exisingpattern" to autoload patterned functions in ksh mode
       
    81 test_functions5()
       
    82 {
       
    83 let totalno=totalno+1
       
    84 echo "Test $totalno: autoload with -mk existingpattern as arguments, to autoload functions with pattem in ksh mode"
       
    85 util_functions4
       
    86 functions -mk util_functions4
       
    87 ret=$?
       
    88 if [ $ret = 0 ]
       
    89 then
       
    90     echo "PASS"
       
    91     let passno=passno+1
       
    92 else
       
    93     echo "FAIL: Expected 0, returned $ret"
       
    94     let failno=failno+1
       
    95 fi
       
    96 }
       
    97 
       
    98 report()
       
    99     {
       
   100     echo "#############################################################################"
       
   101     echo "Total tests : $totalno"
       
   102     echo "Passed      : $passno"
       
   103     echo "Failed      : $failno"
       
   104     echo "#############################################################################"
       
   105     }
       
   106 
       
   107 init
       
   108 test_functions2
       
   109 test_functions3
       
   110 test_functions4
       
   111 test_functions5
       
   112 report