File: clause.dia.ref

package info (click to toggle)
scilab 5.2.2-9
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 334,832 kB
  • ctags: 52,586
  • sloc: xml: 526,945; ansic: 223,590; fortran: 163,080; java: 56,934; cpp: 33,840; tcl: 27,936; sh: 20,397; makefile: 9,908; ml: 9,451; perl: 1,323; cs: 614; lisp: 30
file content (178 lines) | stat: -rw-r--r-- 5,632 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// =============================================================================
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) ????-2008 - INRIA
//
//  This file is distributed under the same license as the Scilab package.
// =============================================================================
// <-- ENGLISH IMPOSED -->
funcprot(0);
deff('[y]=t(x)',[
'y=0'
'if x>0 then'
'  if x==1 then '
'    return'
'  else '
'    if x==2 then '
'       y=10'
'    else '
'       for u=1:x, '
'         y=y+u,'
'       end,'
'       return'
'    end'
'  end'
'else '
'  for u=1:-x, '
'    if u==4 then '
'      return,'
'    else '
'      y=u,'
'    end'
'  end'
'end'],'n')
//
if t(0)<>0 then bugmes();quit;end
if t(1)<>0 then bugmes();quit;end
if t(-1)<>1 then bugmes();quit;end
//
t1=t;
comp(t1)
if t(0)-t1(0)<>0 then bugmes();quit;end
if t(1)-t1(1)<>0 then bugmes();quit;end
if t(-1)-t1(-1)<>0 then bugmes();quit;end
//==========================================================================
//test of break
//==========================================================================
// for in macro
//--------------------------------------
deff('[k]=tt1()','k=0,for i=1:5 ,k=k+1;if k==3 then break,end,end,k=k+1','n')
if tt1()<>4 then bugmes();quit;end
if tt1()<>4 then bugmes();quit;end
clear tt1
deff('[k]=tt1()',[
'k=0,';
'for i=1:5 ,';
'  k=k+1;';
'  if k==3 then break,end,';
'  if k==-1 then 1,end,';
'end,k=k+1'],'n')
if tt1()<>4 then bugmes();quit;end
if tt1()<>4 then bugmes();quit;end
clear tt1
deff('[k]=tt1()',[
'k=0,';
'for i=1:5 ,';
'  k=k+1;';
'  if k==3 then break,end,';
'  for j=1:5,j,end,';
'end,';
'k=k+1'],'n')
if tt1()<>4 then bugmes();quit;end
if tt1()<>4 then bugmes();quit;end
// while
//----------------------------------------
deff('[k]=tt1()','k=0,while k<10 ,k=k+1;if k==3 then break,end,end,k=k+1','n')
if tt1()<>4 then bugmes();quit;end
if tt1()<>4 then bugmes();quit;end
clear tt1
deff('[k]=tt1()',[
'k=0,';
'while k<10 ,';
'  k=k+1;';
'  if k==3 then break,end,';
'  if k==-1 then 1,end,';
'end,k=k+1'],'n')
if tt1()<>4 then bugmes();quit;end
if tt1()<>4 then bugmes();quit;end
clear tt1
deff('[k]=tt1()',[
'k=0,';
'while k<10 ,';
'  k=k+1;';
'  if k==3 then break,end,';
'  for j=1:5,j,end,';
'end,';
'k=k+1'],'n')
if tt1()<>4 then bugmes();quit;end
if tt1()<>4 then bugmes();quit;end
//
// keyboard mode 
//------------------------
k=0;while k<10 ,k=k+1;if k==3 then break,end,end,k=k+1;
if k<>4 then bugmes();quit;end
k=0;while k<10 ,k=k+1;if k==3 then break,end,end,
k=k+1;
if k<>4 then bugmes();quit;end
k=0;for  i=1:5 ,k=k+1;if k==3 then break,end,end,k=k+1;
if k<>4 then bugmes();quit;end
k=0;for  i=1:5 ,k=k+1;if k==3 then break,end,end,
k=k+1;
if k<>4 then bugmes();quit;end
//
k=0;while k<10,if k==0 then break,end,k=k+1;end,k=k+1;
if k<>1 then bugmes();quit;end
k=0;while k<10,if k==0 then break,end,k=k+1;end,
k=k+1;
if k<>1 then bugmes();quit;end
k=0;for i=1:5,if k==0 then break,end,k=k+1;end,k=k+1;
if k<>1 then bugmes();quit;end
k=0;for i=1:5,if k==0 then break,end,k=k+1;end,
k=k+1;
if k<>1 then bugmes();quit;end
//==========================================================================
//test of continue
//==========================================================================
//in a for
//----------
n=3;
c=[];for k=1:5,if k==n then continue,end,c=[c,k];end
if or(c<>[1 2 4 5]) then bugmes();quit;end
n=5;
c=[];for k=1:5,if k==n then continue,end,c=[c,k];end
if or(c<>[1 2 3 4]) then bugmes();quit;end
deff('c=foo(n)','c=[];for k=1:5,if k==n then continue,end,c=[c,k],end','n')
if or(foo(3)<>[1 2 4 5]) then bugmes();quit;end
if or(foo(5)<>[1 2 3 4]) then bugmes();quit;end
comp(foo)
if or(foo(3)<>[1 2 4 5]) then bugmes();quit;end
if or(foo(5)<>[1 2 3 4]) then bugmes();quit;end
n=3;
c=[];for i=1:3,for k=1:4,if k==n&i==2 then continue,end,c=[c,k];end;end
if or(c<>[1,2,3,4, 1,2,4, 1,2,3,4]) then bugmes();quit;end
n=4;
c=[];for i=1:3,for k=1:4,if k==n&i==2 then continue,end,c=[c,k];end;end
if or(c<> [1,2,3,4, 1,2,3, 1,2,3,4]) then bugmes();quit;end
deff('c=foo(n)','c=[];for i=1:3,for k=1:4,if k==n&i==2 then continue,end,c=[c,k];end;end','n')
if or(foo(3)<>[1,2,3,4, 1,2,4, 1,2,3,4]) then bugmes();quit;end
if or(foo(4)<>[1,2,3,4, 1,2,3, 1,2,3,4]) then bugmes();quit;end
comp(foo)
if or(foo(3)<>[1,2,3,4, 1,2,4, 1,2,3,4]) then bugmes();quit;end
if or(foo(4)<>[1,2,3,4, 1,2,3, 1,2,3,4]) then bugmes();quit;end
//in a while
//----------
//
n=3;
c=[];k=0;while k<5,k=k+1;if k==n then continue,end,c=[c,k];end
if or(c<>[1 2 4 5]) then bugmes();quit;end
n=5;
c=[];k=0;while k<5,k=k+1;if k==n then continue,end,c=[c,k];end
if or(c<>[1 2 3 4]) then bugmes();quit;end
deff('c=foo(n)','c=[];k=0;while k<5,k=k+1;if k==n then continue,end,c=[c,k],end','n')
if or(foo(3)<>[1 2 4 5]) then bugmes();quit;end
if or(foo(5)<>[1 2 3 4]) then bugmes();quit;end
comp(foo)
if or(foo(3)<>[1 2 4 5]) then bugmes();quit;end
if or(foo(5)<>[1 2 3 4]) then bugmes();quit;end
n=3;
c=[];for i=1:3,k=0;while k<4,k=k+1;if k==n&i==2 then continue,end,c=[c,k];end;end
if or(c<>[1,2,3,4, 1,2,4, 1,2,3,4]) then bugmes();quit;end
n=4;
c=[];for i=1:3,k=0;while k<4,k=k+1;,if k==n&i==2 then continue,end,c=[c,k];end;end
if or(c<> [1,2,3,4, 1,2,3, 1,2,3,4]) then bugmes();quit;end
clear foo
deff('c=foo(n)','c=[];for i=1:3,k=0;while k<4,k=k+1;if k==n&i==2 then continue,end,c=[c,k];end;end','n')
if or(foo(3)<>[1,2,3,4, 1,2,4, 1,2,3,4]) then bugmes();quit;end
if or(foo(4)<>[1,2,3,4, 1,2,3, 1,2,3,4]) then bugmes();quit;end
comp(foo)
if or(foo(3)<>[1,2,3,4, 1,2,4, 1,2,3,4]) then bugmes();quit;end
if or(foo(4)<>[1,2,3,4, 1,2,3, 1,2,3,4]) then bugmes();quit;end