Merge from vendor branch OPENSSH:
[dragonfly.git] / contrib / bc / Test / TESTS.bc
1 From phil@cs.wwu.edu Mon Mar 20 23:13:22 1995
2 Date: Mon, 20 Mar 1995 23:12:17 -0800
3 From: Phil Nelson <phil@cs.wwu.edu>
4 To: phil@steelhead.cs.wwu.edu
5 Subject: [jhn@ironwood.cray.com: XPG4 bc(1) failures]
6
7 From: jhn@ironwood.cray.com (James Nordby)
8 Subject: XPG4 bc(1) failures
9 To: phil@cs.wwu.edu
10 Date: Fri, 17 Mar 1995 12:14:13 -0600 (CST)
11 X-Mailer: ELM [version 2.4 PL24-CRI-b]
12 Mime-Version: 1.0
13 Content-Type: text/plain; charset=US-ASCII
14 Content-Transfer-Encoding: 7bit
15 Content-Length: 14277     
16
17
18 Phil,
19
20 Here are the test results I'm getting from the XPG4 test suite,
21 with some explanation and fixes so far.  Let me know what you
22 think...
23
24 Thanks much,
25 Jim Nordby (jhn@cray.com)
26
27
28 --------  bc                    08:38:34  --------
29
30 Assertion #20 (A): bc reads text files
31 Expected exit code = 0; Received 139
32 Standard output isn't the same as file 'bc_eso_20_1'
33 diff of "out.stdout" and "bc_eso_20_1":
34 *** out.stdout  Fri Mar 17 08:39:22 1995
35 --- bc_eso_20_1 Fri Mar 17 08:39:22 1995
36 ***************
37 *** 0 ****
38 --- 1,31 ----
39 + 11111111111111111111111111111111111111111111111111111111111111111111
40 + 11111111111111111111111111111111111111111111111111111111111111111111
41 + 11111111111111111111111111111111111111111111111111111111111111111111
42 + 11111111111111111111111111111111111111111111111111111111111111111111
43 + 11111111111111111111111111111111111111111111111111111111111111111111
44 + 11111111111111111111111111111111111111111111111111111111111111111111
45 + 11111111111111111111111111111111111111111111111111111111111111111111
46 + 11111111111111111111111111111111111111111111111111111111111111111111
47 + 11111111111111111111111111111111111111111111111111111111111111111111
48 + 11111111111111111111111111111111111111111111111111111111111111111111
49 + 11111111111111111111111111111111111111111111111111111111111111111111
50 + 11111111111111111111111111111111111111111111111111111111111111111111
51 + 11111111111111111111111111111111111111111111111111111111111111111111
52 + 11111111111111111111111111111111111111111111111111111111111111111111
53 + 11111111111111111111111111111111111111111111111111111111111111111111
54 + 11111111111111111111111111111111111111111111111111111111111111111111
55 + 11111111111111111111111111111111111111111111111111111111111111111111
56 + 11111111111111111111111111111111111111111111111111111111111111111111
57 + 11111111111111111111111111111111111111111111111111111111111111111111
58 + 11111111111111111111111111111111111111111111111111111111111111111111
59 + 11111111111111111111111111111111111111111111111111111111111111111111
60 + 11111111111111111111111111111111111111111111111111111111111111111111
61 + 11111111111111111111111111111111111111111111111111111111111111111111
62 + 11111111111111111111111111111111111111111111111111111111111111111111
63 + 11111111111111111111111111111111111111111111111111111111111111111111
64 + 11111111111111111111111111111111111111111111111111111111111111111111
65 + 11111111111111111111111111111111111111111111111111111111111111111111
66 + 11111111111111111111111111111111111111111111111111111111111111111111
67 + 11111111111111111111111111111111111111111111111111111111111111111111
68 + 11111111111111111111111111111111111111111111111111111111111111111111
69 + 1111111
70 Assertion Result: FAIL
71
72 I couldn't reproduce this problem; when I rebuilt your bc and
73 ran it, I got a different problem with printing out a large
74 number.  The XPG4 tests expected lines to be 70 characters
75 long, INCLUDING the newline (this comes from the POSIX definition
76 of a line).  To fix it, I changed util.c like so:
77
78 *** util.c      Thu Mar 16 10:47:36 1995
79 --- util.c.old  Thu Mar 16 10:50:10 1995
80 ***************
81 *** 309,323 ****
82     else
83       {
84         out_col++;
85 - #ifdef _CRAY
86 -       /*
87 -        * XPG4 considers a line to include the <newline>;
88 -        * therefore we want 68 numerals, <backslash>, <newline>
89 -        */
90 -       if (out_col == 69)
91 - #else
92         if (out_col == 70)
93 - #endif
94         {
95           putchar ('\\');
96           putchar ('\n');
97 --- 309,315 ----
98
99
100
101
102
103
104 Assertion #42 (A): check reserved words
105 Standard error isn't empty
106 Contents of out.stderr:
107 (standard_in) 6: syntax error
108 (standard_in) 15: syntax error
109 Standard output isn't the same as file 'bc_eso_42_1'
110 diff of "out.stdout" and "bc_eso_42_1":
111 *** out.stdout  Fri Mar 17 08:39:43 1995
112 --- bc_eso_42_1 Fri Mar 17 08:39:43 1995
113 ***************
114 *** 1,2 ****
115 --- 1,3 ----
116   2
117   1
118 + 0
119 Assertion Result: FAIL
120
121 This one is debatable, based on the grammar in the POSIX manual.
122 Here's the input file:
123
124 cat << \VSC-EOF > input
125 define a() {
126         auto b;
127         for ( b = 0; b < 10; b++ ) {
128                 b;
129                 if ( b == 1 )
130                         break;
131         }
132         return ( 5 ) ;
133 }
134 ibase = 10;
135 length ( obase );
136 scale = 0;
137 sqrt(1);
138 while ( a() != 5 )
139 VSC-EOF
140
141 They want these constructs to be accepted:
142
143
144 if (b == 1)
145         whatever;
146 for (x = 0; x < 10; x++)
147         whatever;
148 while (x < 10)
149         whatever;
150
151 rather than just
152
153 if (b == 1) {
154         whatever
155 }
156 etc.
157
158 The grammar as it's currently worded requires a '{' before hitting
159 a NEWLINE for these constructs.  It's easy enough to change in bc.y
160 (see below), but if I do change it, it still barfs on the last
161 line of the file ( 'while (a() != 5)' ).  Since the while lacks
162 a body, it gives a syntax error; they're expecting a '0' to be
163 returned.  The grammar could be changed to support this, but is
164 it a good idea?
165
166
167 *** bc.y        Thu Mar 16 10:47:20 1995
168 --- bc.y.old    Thu Mar 16 10:50:11 1995
169 ***************
170 *** 142,150 ****
171                         | error statement
172                             { $$ = $2; }
173                         ;
174 - allow_newlines                : /* empty */
175 -                       | NEWLINE allow_newlines
176 -                       ;
177   statement             : Warranty
178                             { warranty (""); }
179                         | Limits
180 --- 142,147 ----
181 ***************
182 *** 231,237 ****
183                                 sprintf (genstr, "pJ%1d:N%1d:", $4, $7);
184                               generate (genstr);
185                             }
186 !                         allow_newlines statement
187                             {
188                               sprintf (genstr, "J%1d:N%1d:",
189                                        continue_label, break_label);
190 --- 228,234 ----
191                                 sprintf (genstr, "pJ%1d:N%1d:", $4, $7);
192                               generate (genstr);
193                             }
194 !                         statement
195                             {
196                               sprintf (genstr, "J%1d:N%1d:",
197                                        continue_label, break_label);
198 ***************
199 *** 246,252 ****
200                               sprintf (genstr, "Z%1d:", if_label);
201                               generate (genstr);
202                             }
203 !                         allow_newlines statement  opt_else
204                             {
205                               sprintf (genstr, "N%1d:", if_label); 
206                               generate (genstr);
207 --- 243,249 ----
208                               sprintf (genstr, "Z%1d:", if_label);
209                               generate (genstr);
210                             }
211 !                         statement  opt_else
212                             {
213                               sprintf (genstr, "N%1d:", if_label); 
214                               generate (genstr);
215 ***************
216 *** 265,271 ****
217                               sprintf (genstr, "Z%1d:", break_label);
218                               generate (genstr);
219                             }
220 !                       ')' allow_newlines statement
221                             {
222                               sprintf (genstr, "J%1d:N%1d:", $1, break_label);
223                               generate (genstr);
224 --- 262,268 ----
225                               sprintf (genstr, "Z%1d:", break_label);
226                               generate (genstr);
227                             }
228 !                       ')' statement
229                             {
230                               sprintf (genstr, "J%1d:N%1d:", $1, break_label);
231                               generate (genstr);
232
233
234
235
236 Assertion #49 (A): check strings
237 Expected exit code = 0; Received 1
238 Standard error isn't empty
239 Contents of out.stderr:
240 File (NULL) is unavailable.
241 Standard output isn't the same as file 'bc_eso_49_1'
242 diff of "out.stdout" and "bc_eso_49_1":
243 cmd-1794 diff: Missing newline at end of file 'bc_eso_49_1'.
244 *** out.stdout  Fri Mar 17 08:40:01 1995
245 --- bc_eso_49_1 Fri Mar 17 08:40:01 1995
246 ***************
247 *** 0 ****
248 --- 1 ----
249 + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
250 *LINE CONTINUATION -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
251 *LINE CONTINUATION -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
252 Assertion Result: FAIL
253
254 This gist of this is that the standard expects numbers to
255 be truncated to 70 characters, but STRINGS should not.
256 My changes to fix this are:
257
258
259 *** execute.c   Thu Mar 16 13:06:39 1995
260 --- execute.c.old       Thu Mar 16 10:50:09 1995
261 ***************
262 *** 208,218 ****
263         case 'O' : /* Write a string to the output with processing. */
264         while ((ch = byte(&pc)) != '"')
265           if (ch != '\\')
266 - #ifdef _CRAY
267 -           putchar (ch);
268 - #else
269             out_char (ch);
270 - #endif
271           else
272             {
273               ch = byte(&pc);
274 --- 207,213 ----
275 ***************
276 *** 219,234 ****
277               if (ch == '"') break;
278               switch (ch)
279                 {
280 - #ifdef _CRAY
281 -               case 'a':  putchar (007); break;
282 -               case 'b':  putchar ('\b'); break;
283 -               case 'f':  putchar ('\f'); break;
284 -               case 'n':  putchar ('\n'); break;
285 -               case 'q':  putchar ('"'); break;
286 -               case 'r':  putchar ('\r'); break;
287 -               case 't':  putchar ('\t'); break;
288 -               case '\\': putchar ('\\'); break;
289 - #else
290                 case 'a':  out_char (007); break;
291                 case 'b':  out_char ('\b'); break;
292                 case 'f':  out_char ('\f'); break;
293 --- 214,219 ----
294 ***************
295 *** 237,243 ****
296                 case 'r':  out_char ('\r'); break;
297                 case 't':  out_char ('\t'); break;
298                 case '\\': out_char ('\\'); break;
299 - #endif
300                 default:  break;
301                 }
302             }
303 --- 222,227 ----
304 ***************
305 *** 350,360 ****
306         break;
307   
308         case 'w' : /* Write a string to the output. */
309 - #ifdef _CRAY
310 -       while ((ch = byte(&pc)) != '"') putchar (ch);
311 - #else
312         while ((ch = byte(&pc)) != '"') out_char (ch);
313 - #endif
314         if (interactive) fflush (stdout);
315         break;
316                    
317
318
319
320 Assertion #77 (C): output longer than 70 characters
321 Standard output isn't the same as file 'bc_eso_77_1'
322 diff of "out.stdout" and "bc_eso_77_1":
323 *** out.stdout  Fri Mar 17 08:41:13 1995
324 --- bc_eso_77_1 Fri Mar 17 08:41:13 1995
325 ***************
326 *** 1,2 ****
327 ! 3.3333333333333333333333333333333333333333333333333333333333333333333
328 ! 33333333333333333333333333333333
329 --- 1,2 ----
330 ! 3.333333333333333333333333333333333333333333333333333333333333333333
331 ! 333333333333333333333333333333333
332 Assertion Result: FAIL
333
334 Same as assertion #20 above...
335
336
337
338
339 Assertion #92 (A): check %
340 Standard output isn't the same as file 'bc_eso_92_1'
341 diff of "out.stdout" and "bc_eso_92_1":
342 *** out.stdout  Fri Mar 17 08:41:33 1995
343 --- bc_eso_92_1 Fri Mar 17 08:41:33 1995
344 ***************
345 *** 4,8 ****
346   4
347   15
348   1
349 ! 0
350 ! 0
351 --- 4,8 ----
352   4
353   15
354   1
355 ! 6
356 ! 5
357 Assertion Result: FAIL
358
359 This one is a pain.  The failing code looks like this:
360
361 scale = 4
362 scale ( 5.000000 % 2.0 )
363 scale ( 5.00 % 2.0 )
364
365 They expect '6' and '5' for output, instead of '0', based on
366 the explanation of the modulus operator ("scale of the result
367 shall be 'max(scale + scale(b), scale(a)'"), even though the
368 result is a 0.  I was able to fix this problem by the change
369 below:
370
371 *** number.c    Thu Mar 16 13:15:43 1995
372 --- number.c.old        Thu Mar 16 10:50:09 1995
373 ***************
374 *** 614,623 ****
375         case  0:
376           /* They are equal! return zero! */
377           diff = copy_num (_zero_);   
378 - #ifdef _CRAY
379 -         /* correct the scale here */
380 -         diff->n_scale = MAX (n1->n_scale, n2->n_scale);
381 - #endif
382           break;
383         case  1:
384           /* n2 is less than n1, subtract n2 from n1. */
385
386 but this causes another test failure that I haven't looked at.
387
388
389
390
391 Assertion #130 (A): functions are call by value
392 Standard output isn't the same as file 'bc_eso_130_1'
393 diff of "out.stdout" and "bc_eso_130_1":
394 *** out.stdout  Fri Mar 17 08:42:24 1995
395 --- bc_eso_130_1        Fri Mar 17 08:42:24 1995
396 ***************
397 *** 4,10 ****
398   5
399   4
400   0
401 ! 4
402   3
403   3
404   5
405 --- 4,10 ----
406   5
407   4
408   0
409 ! 5
410   3
411   3
412   5
413 Assertion Result: FAIL
414
415 Assertion #131 (A): functions are call by value
416 Standard output isn't the same as file 'bc_eso_131_1'
417 diff of "out.stdout" and "bc_eso_131_1":
418 *** out.stdout  Fri Mar 17 08:42:28 1995
419 --- bc_eso_131_1        Fri Mar 17 08:42:28 1995
420 ***************
421 *** 4,10 ****
422   5
423   4
424   0
425 ! 4
426   3
427   3
428   5
429 --- 4,10 ----
430   5
431   4
432   0
433 ! 5
434   3
435   3
436   5
437 Assertion Result: FAIL
438
439
440 Both of these are the 'arrays are passed by value' problem.
441 One of the test cases is below:
442
443 cat << \VSC-EOF > bc_in_130_1
444 a[0] = 3
445 a[0]
446 define b(a[]) {
447 a[0]
448 a[0] = 4
449 a[0]
450 }
451 a[0]
452 a[0] = 5
453 a[0]
454 b(a[])
455 a[0]
456 VSC-EOF
457
458 They expect the assignment of a[0] inside the b() function
459 to not affect a[0] outside of the function.
460
461
462
463
464
465 Assertion #139 (A): check sin
466 Standard output isn't the same as file 'bc_eso_139_1'
467 diff of "out.stdout" and "bc_eso_139_1":
468 *** out.stdout  Fri Mar 17 08:42:40 1995
469 --- bc_eso_139_1        Fri Mar 17 08:42:39 1995
470 ***************
471 *** 1,5 ****
472   0
473 ! 20
474   1.68294196961579301330
475   20
476   1.6829419696
477 --- 1,5 ----
478   0
479 ! 0
480   1.68294196961579301330
481   20
482   1.6829419696
483 Assertion Result: FAIL
484
485 Assertion #141 (A): check arctanngent
486 Standard output isn't the same as file 'bc_eso_141_1'
487 diff of "out.stdout" and "bc_eso_141_1":
488 *** out.stdout  Fri Mar 17 08:42:44 1995
489 --- bc_eso_141_1        Fri Mar 17 08:42:44 1995
490 ***************
491 *** 1,5 ****
492   0
493 ! 20
494   3.14159265358979323844
495   20
496   3.1415926532
497 --- 1,5 ----
498   0
499 ! 0
500   3.14159265358979323844
501   20
502   3.1415926532
503 Assertion Result: FAIL
504
505 Assertion #142 (A): check log
506 Standard output isn't the same as file 'bc_eso_142_1'
507 diff of "out.stdout" and "bc_eso_142_1":
508 *** out.stdout  Fri Mar 17 08:42:47 1995
509 --- bc_eso_142_1        Fri Mar 17 08:42:47 1995
510 ***************
511 *** 1,5 ****
512   0
513 ! 20
514   2.30258509299404568401
515   20
516   2.3025850929
517 --- 1,5 ----
518   0
519 ! 0
520   2.30258509299404568401
521   20
522   2.3025850929
523 Assertion Result: FAIL
524
525 Assertion #144 (A): check bessel
526 Standard output isn't the same as file 'bc_eso_144_1'
527 diff of "out.stdout" and "bc_eso_144_1":
528 *** out.stdout  Fri Mar 17 08:42:51 1995
529 --- bc_eso_144_1        Fri Mar 17 08:42:51 1995
530 ***************
531 *** 1,5 ****
532   0
533 ! 20
534   .57672480775687338720
535   20
536   .5767248077
537 --- 1,5 ----
538   0
539 ! 0
540   .57672480775687338720
541   20
542   .5767248077
543 Assertion Result: FAIL
544
545 All of these are the same.  I'll give you the test case
546 for 'sin'; what they're expecting is 0:
547
548 scale(s(0))
549
550 bc outputs '20' (which is the scale at the time), but the
551 interpretation of the standard says that it should be '0',
552 since s(0) is 0, and the scale of 0 is 0.  I think that
553 this interpretation disagrees with one of the previous
554 assertions (assertion #92).
555
556 /* end of test results */
557
558
559
560 -- 
561 Phil Nelson
562 e-mail: phil@cs.wwu.edu
563 http://www.cs.wwu.edu/~phil
564
565