1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2006-2008 - INRIA - Serge STEER <serge.steer@inria.fr>
5 // This file is distributed under the same license as the Scilab package.
6 // =============================================================================
8 // <-- CLI SHELL MODE -->
9 // <-- ENGLISH IMPOSED -->
11 // <-- Non-regression test for bug 1469 -->
13 // <-- Bugzilla URL -->
14 // http://bugzilla.scilab.org/show_bug.cgi?id=1469
16 // <-- Short Description -->
17 // Comments modify line numbering in functions
19 // What you don't believe?
23 // 1st test, no comment in line 1:
28 // --> disp("line a");
29 // --> disp("line b");
30 // --> disp("line c");
33 // -->setbpt("foo1",[3,4])
36 // Stop after row 3 in function foo1 :
38 //test of line numbering in functions, handling initial comments
39 // ================ Test 1 =====================================================
40 function foo,endfunction
42 R1=L(6)==1&size(L)==6;
43 if ~R1 then bugmes();quit;end
45 // ================ Test 2 =====================================================
46 // known syntax error in scilab 6
47 //function foo,,endfunction
49 //R2=L(6)==1&size(L)==6
50 //if ~R2 then bugmes();quit;end
52 // ================ Test 3 =====================================================
53 function foo(),endfunction
55 R3=L(6)==1&size(L)==6;
56 if ~R3 then bugmes();quit;end
58 // ================ Test 4 =====================================================
59 function foo(),a=1,endfunction
61 R4=L(6)==1&size(L)==6;
62 if ~R4 then bugmes();quit;end
64 // ================ Test 5 =====================================================
68 R5=L(6)==2&size(L)==6;
69 if ~R5 then bugmes();quit;end
71 // ================ Test 6 =====================================================
75 R6=L(6)==2&size(L)==6;
76 if ~R6 then bugmes();quit;end
78 // ================ Test 7 =====================================================
82 R7=L(6)==2&size(L)==6;
83 if ~R7 then bugmes();quit;end
85 // ================ Test 8 =====================================================
89 R8=L(6)==2&size(L)==6;
90 if ~R8 then bugmes();quit;end
92 // ================ Test 9 =====================================================
97 R9=L(6)==3&size(L)==6;
98 if ~R9 then bugmes();quit;end
100 // ================ Test 10 ====================================================
105 R10=L(6)==3&size(L)==6;
106 if ~R10 then bugmes();quit;end
108 // ================ Test 11 ====================================================
109 function loc=foo,[l,w]=where(),loc=l(1),endfunction
111 if ~R11 then bugmes();quit;end
113 // ================ Test 12 ====================================================
114 function loc=foo,//ZZZZ
115 [l,w]=where(),loc=l(1)
118 if ~R12 then bugmes();quit;end
120 // ================ Test 13 ====================================================
123 [l,w]=where(),loc=l(1)
126 if ~R13 then bugmes();quit;end
128 // ================ Test 14 ====================================================
130 [l,w]=where(),loc=l(1)
131 function loc=foo3(loc)
132 [l,w]=where(),loc=[loc,l(1:2)']
134 [l,w]=where(),loc=[loc,l(1)]
137 R14= and(foo1()==[2,6,2,7]);
138 if ~R14 then bugmes();quit;end
140 // ================ Test 15 ====================================================
141 function loc=foo1()//ZZZZZZZ
142 [l,w]=where(),loc=l(1)
143 function loc=foo3(loc)
144 [l,w]=where(),loc=[loc,l(1:2)']
146 [l,w]=where(),loc=[loc,l(1)]
150 R15=and(foo1()==[2,6,2,7])&(L(6)==8);
151 if ~R15 then bugmes();quit;end
153 // ================ Test 16 ====================================================
156 [l,w]=where(),loc=l(1)
157 function loc=foo3(loc)
158 [l,w]=where(),loc=[loc,l(1:2)']
160 [l,w]=where(),loc=[loc,l(1)]
164 R16=and(foo1()==[3,7,2,8])&(L(6)==9);
165 if ~R16 then bugmes();quit;end
167 // ================ Test 17 ====================================================
168 //pb execution des macros non compilee
169 deff("y=foo(a,b,c)","y=a+b+c");
170 R17=foo("aaa","bbb","cc")=="aaabbbcc";
171 if ~R17 then bugmes();quit;end
173 // ================ Test 18 ====================================================
174 deff("y=foo(a,b,c)",["","y=a+b+c"]);
175 R18=foo("aaa","bbb","cc")=="aaabbbcc";
176 if ~R18 then bugmes();quit;end
178 // ================ Test 19 ====================================================
179 // comp is obsolete since Scilab 6
181 //R19=foo('aaa','bbb','cc')=='aaabbbcc'
182 //if ~R19 then bugmes();quit;end
184 // ================ Test 20 ====================================================
185 //function definition nested in a or loop!
196 if ~R20 then bugmes();quit;end
197 // ================ Test 21 ====================================================
199 t=["function foo,//ZZZZ"
202 mputl(t,TMPDIR+"/foo.sci");
204 exec(TMPDIR+"/foo.sci")
209 L=macr2tree(foo); //getf ignores declaration line comments
210 R21=L(6)==3&size(L)==6;
211 if ~R21 then bugmes();quit;end
213 // ================ Test 22 ====================================================
218 mputl(t,TMPDIR+"/foo.sci");
219 exec(TMPDIR+"/foo.sci")
224 L=macr2tree(foo); //getf ignores declaration line comments
225 R22=L(6)==4&size(L)==6;
226 if ~R22 then bugmes();quit;end
228 // ================ Test 23 ====================================================
236 if size(t,1)<>6 then bugmes();quit;end
245 if or(t<>t1) then bugmes();quit;end
246 // ================ Test 24 ====================================================
247 function test;endfunction
249 if size(L)<>6 then bugmes();quit;end
250 if L(6)<>1 then bugmes();quit;end