|
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 # Autoload -X loads the function to replace existing one, and gets executed |
|
15 # |
|
16 |
|
17 init() |
|
18 { |
|
19 let totalno=0; |
|
20 let passno=0; |
|
21 let failno=0; |
|
22 } |
|
23 |
|
24 test_autoload2() |
|
25 { |
|
26 let totalno=totalno+1 |
|
27 echo "Test $totalno: autoload with one -X argument" |
|
28 autoload -X |
|
29 ret=$? |
|
30 if [ $ret = 1 ] |
|
31 then |
|
32 echo "PASS" |
|
33 let passno=passno+1 |
|
34 else |
|
35 echo "FAIL: Expected 1, returned $ret" |
|
36 let failno=failno+1 |
|
37 fi |
|
38 } |
|
39 |
|
40 |
|
41 # Autoload +z loads the function in zsh mode |
|
42 test_autoload3() |
|
43 { |
|
44 let totalno=totalno+1 |
|
45 echo "Test $totalno: autoload with one +z argument, to load the function in zsh mode" |
|
46 autoload +z |
|
47 ret=$? |
|
48 if [ $ret = 0 ] |
|
49 then |
|
50 echo "PASS" |
|
51 let passno=passno+1 |
|
52 else |
|
53 echo "FAIL: Expected 0, returned $ret" |
|
54 let failno=failno+1 |
|
55 fi |
|
56 } |
|
57 |
|
58 |
|
59 |
|
60 #autoload +k loads the function in ksh mode |
|
61 test_autoload4() |
|
62 { |
|
63 let totalno=totalno+1 |
|
64 echo "Test $totalno: autoload with one +k argument, to load the function in ksh mode" |
|
65 autoload +z |
|
66 ret=$? |
|
67 if [ $ret = 0 ] |
|
68 then |
|
69 echo "PASS" |
|
70 let passno=passno+1 |
|
71 else |
|
72 echo "FAIL: Expected 0, returned $ret" |
|
73 let failno=failno+1 |
|
74 fi |
|
75 } |
|
76 |
|
77 # autoload -kz as invalid option |
|
78 test_autoload5() |
|
79 { |
|
80 let totalno=totalno+1 |
|
81 echo "Test $totalno: autoload with one -kz argument, to display invalid option" |
|
82 autoload -kz |
|
83 ret=$? |
|
84 if [ $ret = 1 ] |
|
85 then |
|
86 echo "PASS" |
|
87 let passno=passno+1 |
|
88 else |
|
89 echo "FAIL: Expected 1, returned $ret" |
|
90 let failno=failno+1 |
|
91 fi |
|
92 } |
|
93 |
|
94 # "autoload +" to print names only of autoloaded functions |
|
95 test_autoload6() |
|
96 { |
|
97 let totalno=totalno+1 |
|
98 echo "Test $totalno: autoload with one + argument, to display names of autoloaded functions" |
|
99 autoload + |
|
100 ret=$? |
|
101 if [ $ret = 0 ] |
|
102 then |
|
103 echo "PASS" |
|
104 let passno=passno+1 |
|
105 else |
|
106 echo "FAIL: Expected 0, returned $ret" |
|
107 let failno=failno+1 |
|
108 fi |
|
109 } |
|
110 |
|
111 |
|
112 # "autoload -Uu" to print bad option -u |
|
113 test_autoload7() |
|
114 { |
|
115 let totalno=totalno+1 |
|
116 echo "Test $totalno: autoload withe -Uu as argument, to display bad option -u" |
|
117 autoload -Uu |
|
118 ret=$? |
|
119 if [ $ret = 1 ] |
|
120 then |
|
121 echo "PASS" |
|
122 let passno=passno+1 |
|
123 else |
|
124 echo "FAIL: Expected 1, returned $ret" |
|
125 let failno=failno+1 |
|
126 fi |
|
127 } |
|
128 |
|
129 # "autoload -w somearg" tries to load zwc file to autoload |
|
130 test_autoload8() |
|
131 { |
|
132 let totalno=totalno+1 |
|
133 echo "Test $totalno: autoload with "-w somearg" as argument, to display error: Cannot open zwc file: somearg.zwc" |
|
134 autoload -w somearg |
|
135 ret=$? |
|
136 if [ $ret = 1 ] |
|
137 then |
|
138 echo "PASS" |
|
139 let passno=passno+1 |
|
140 else |
|
141 echo "FAIL: Expected 1, returned $ret" |
|
142 let failno=failno+1 |
|
143 fi |
|
144 } |
|
145 |
|
146 report() |
|
147 { |
|
148 echo "#############################################################################" |
|
149 echo "Total tests : $totalno" |
|
150 echo "Passed : $passno" |
|
151 echo "Failed : $failno" |
|
152 echo "#############################################################################" |
|
153 } |
|
154 |
|
155 init |
|
156 test_autoload2 |
|
157 test_autoload3 |
|
158 test_autoload4 |
|
159 test_autoload5 |
|
160 test_autoload6 |
|
161 test_autoload7 |
|
162 test_autoload8 |
|
163 report |