1() = evalfile ("inc.sl");
2print ("Known Bugs or not yet implemented features:\n");
3implements ("bugs");
4
5static define f()
6{
7   _pop_n (_NARGS);
8   return _NARGS;
9}
10
11static variable A = [&f];
12if (3 != (@A[0])(1,2,3))
13  vmessage ("\tArray indexing/_NARGS interaction still present: %d",
14	    (@A[0])(1,2,3));
15
16static define func1(p1, p2) { return _NARGS; }
17static variable A = [ &func1, &func1 ];
18define test(which) { (@A[which])(which, which);}
19if (2 != test(0))
20  vmessage ("\tArray indexing/deref/_NARGS interaction present");
21A = &f;
22if (3 != (@A)(4,5,6))
23  vmessage ("\tderef/_NARGS interaction present");
24
25static variable s = struct
26{
27   method
28};
29s.method = &f;
30if (3 != (@s.method)(4,5,6))
31  vmessage ("\tUnexpected struct method/_NARGS interaction");
32if (4 != s.method(7,8,9))
33  vmessage ("\tUnexpected struct method call/_NARGS interaction");
34
35if (1)
36{
37   $1 = 0;
38   ERROR_BLOCK
39     {
40	$1 = 1;
41	_clear_error();
42     }
43   static variable A = Assoc_Type[Int_Type];
44   A["foo"] = [1:10];
45   if ($1 == 0)
46     vmessage ("\tAssoc_Type/Array conflict present");
47   %else
48   %  vmessage ("\tIgnore above error.");
49}
50
51$1 = [1L,1]; $1 = [1,1L];
52
53$1 = Double_Type[2,2];
54$1[*] = PI;
55if (length (where ($1 == PI)) != length ($1))
56  vmessage ("\tA[*] where A is multidimensional");
57
58% This _used_ to cause a subtle leak
59typedef struct {a} Foo_Type;
60()=[Struct_Type[1],@Foo_Type];
61
62#iffalse
63% This "broken-feature" is nolonger supported.
64$1 = [1:10];
65if (10 != length ($1[[0:-1]]))
66  vmessage ("\tSubscripting a 1d array with negative indices");
67$1 = _reshape ($1, [5,2]);
68if (10 != length ($1[[0:-1]]))
69  vmessage ("\tSubscripting a 2d array with negative indices");
70#endif
71
72if (1)
73{
74   $1 = 0;
75   ERROR_BLOCK
76     {
77	_clear_error();
78	vmessage ("case Array_Type bug present");
79     }
80   switch ($1)
81     {
82      case "hello":
83	failed ("case");
84     }
85     {
86      case [1:10]:
87	failed ("case");
88     }
89}
90
91static define foo ()
92{
93   return "foo";
94}
95static define bar ()
96{
97   return "bar";
98}
99static variable A = [&foo, &bar];
100if ("bar" != (@A[1])())
101  vmessage ("Dereferencing a array element bug");
102
103A = Struct_Type[2];
104static variable S = struct
105{
106   addr
107};
108A[0] = S;
109A[1] = @S;
110
111A[0].addr = &$1;
112A[1].addr = &$2;
113
114try
115{
116   eval ("@A[0].addr = PI", "bugs");
117   eval ("@(A[0].addr) = PI", "bugs");
118}
119catch NotImplementedError:
120{
121   vmessage ("\tDereferencing an array of struct fields");
122}
123
124static define test_xxx (xxx)
125{
126   variable x=0, y=0;
127   loop (3)
128     {
129	x++;
130	try eval(sprintf ("if (1) %s;", xxx));
131	catch SyntaxError;
132	y++;
133     }
134   return 10*y+x;
135}
136
137if (test_xxx ("break") != 33)
138  vmessage ("\tbreak at top-level");
139
140if (test_xxx ("continue") != 33)
141  vmessage ("\tcontinue at top-level");
142
143if (test_xxx ("return") != 33)
144  vmessage ("\treturn at top-level");
145
146static define test_function_name ()
147{
148   return eval ("_function_name()");
149}
150if ("" != test_function_name ())
151  vmessage ("\t_function_name at top-level");
152
153try
154{
155   $1 = Int_Type[10];
156   eval("() = &$1[0];");
157   %vmessage ("**** Expecting &X[0] to generate an error!!!");
158}
159catch NotImplementedError: vmessage ("\t&s[0] not supported");
160try
161{
162   $1 = struct {foo};
163   eval("() = &$1.foo;");
164   %vmessage ("**** Expecting &s.foo to generate an error!!!");
165}
166catch NotImplementedError: vmessage ("\t&s.foo not supported");
167
168try
169{
170   eval ("()++;--();++();");
171   vmessage ("**** ++() not being caught by the parser!!!");
172}
173catch SyntaxError;
174
175private define foo (i, x)
176{
177   if (x != NULL)
178     throw TypeMismatchError;
179   return int (i);
180}
181
182define test_array_map_bug ()
183{
184   try
185     {
186	() = array_map (Int_Type, &foo, [1:10], NULL);
187     }
188   catch AnyError:
189     {
190	vmessage ("\tarray_map bug present with NULL present");
191     }
192}
193test_array_map_bug ();
194
195define test_range_array_bug ()
196{
197   variable a = {1h, 1, 1L, 1LL};
198   foreach (a)
199     {
200	variable i = ();
201	if (_typeof ([i:i]) == typeof (i))
202	  continue;
203	vmessage ("\tRange arrays of Short, Long, LongLong types converted to Int_Type");
204	return;
205     }
206}
207test_range_array_bug ();
208
209define test_overzealous_tmp_opt_bug ()
210{
211   variable a = Array_Type[1];
212   a[0] = [1];
213   () = a + 1;
214   if (a[0][0] != 1)
215     vmessage ("\tOver-zealous __tmp optimization array bug present");
216}
217test_overzealous_tmp_opt_bug ();
218
219define test_array_index_bug ()
220{
221   variable x = Double_Type[7];
222   try
223     {
224	x[[1:7]] = 0.0;
225     }
226   catch IndexError: return;
227   throw InternalError, "test_array_index_bug: this bug has returned.";
228}
229test_array_index_bug ();
230
231exit (0);
232
233