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
  
179
  
180
  
181
  
182
  
183
  
184
  
185
  
186
  
187
  
188
  
189
  
190
  
191
  
192
  
193
  
194
  
195
  
196
  
197
  
198
  
199
  
200
  
201
  
202
  
203
  
204
  
205
  
206
  
207
  
208
  
209
  
210
  
211
  
212
  
213
  
214
  
215
  
216
  
217
  
218
  
219
  
220
  
221
  
222
  
223
  
224
  
225
  
226
  
227
  
228
  
229
  
230
  
231
  
232
  
233
  
234
  
235
  
236
  
237
  
238
  
239
  
240
  
241
  
242
  
243
  
244
  
245
  
246
  
247
  
248
  
249
  
250
  
251
  
252
  
253
  
254
  
255
  
256
  
257
  
258
  
259
  
260
  
261
  
262
  
263
  
264
  
265
  
266
  
267
  
268
  
269
  
270
  
271
  
272
  
273
  
274
  
275
  
276
  
277
  
278
  
279
  
280
  
281
  
282
  
283
  
284
  
285
  
286
  
287
  
288
  
289
  
290
  
291
  
292
  
293
  
294
  
295
  
296
  
297
  
298
  
299
  
300
  
301
  
302
  
303
  
304
  
305
  
306
  
307
  
308
  
309
  
310
  
311
  
312
  
313
  
314
  
315
  
316
  
317
  
318
  
319
  
320
  
321
  
322
  
323
  
324
  
325
  
326
  
327
  
328
  
329
  
330
  
331
  
332
  
333
  
334
  
335
  
336
  
337
  
338
  
339
  
340
  
341
  
342
  
343
  
344
  
345
  
346
  
347
  
348
  
349
  
350
  
351
  
352
  
353
  
354
  
355
  
356
  
357
  
358
  
359
  
360
  
361
  
362
  
363
  
364
  
365
  
366
  
367
  
368
  
369
  
370
  
371
  
372
  
373
  
374
  
375
  
376
  
377
  
378
  
379
  
380
  
381
  
382
  
383
  
384
  
385
  
386
  
387
  
388
  
389
  
390
  
391
  
392
  
393
  
394
  
395
  
396
  
397
  
398
  
399
  
400
  
401
  
402
  
403
  
404
  
405
  
406
  
407
  
408
  
409
  
410
  
411
  
412
  
413
  
414
  
415
  
416
  
417
  
418
  
419
  
420
  
421
  
422
  
423
  
424
  
425
  
426
  
427
  
428
  
429
  
430
  
431
  
432
  
433
  
434
  
435
  
436
  
437
  
438
  
439
  
440
  
441
  
442
  
443
  
444
  
445
  
446
  
447
  
448
  
449
  
450
  
451
  
452
  
453
  
454
  
455
  
456
  
457
  
458
  
459
  
460
  
461
  
462
  
463
  
464
  
465
  
466
  
467
  
468
  
469
  
470
  
471
  
472
  
473
  
474
  
475
  
476
  
477
  
478
  
479
  
480
  
481
  
482
  
483
  
484
  
485
  
486
  
487
  
488
  
489
  
490
  
491
  
492
  
493
  
494
  
495
  
496
  
497
  
498
  
499
  
500
  
501
  
502
  
503
  
504
  
505
  
506
  
507
  
508
  
509
  
510
  
511
  
512
  
513
  
514
  
515
  
516
  
517
  
518
  
519
  
520
  
521
  
522
  
523
  
524
  
525
  
526
  
527
  
528
  
529
  
530
  
531
  
532
  
533
  
534
  
535
  
536
  
537
  
538
  
539
  
540
  
541
  
542
  
543
  
544
  
545
  
546
  
547
  
548
  
549
  
550
  
551
  
552
  
553
  
554
  
555
  
556
  
557
  
558
  
559
  
560
  
561
  
562
  
563
  
564
  
565
  
566
  
567
  
568
  
569
  
570
  
571
  
572
  
573
  
574
  
575
  
576
  
577
  
578
  
579
  
580
  
581
  
582
  
583
  
584
  
585
  
586
  
587
  
588
  
589
  
590
  
591
  
592
  
593
  
594
  
595
  
596
  
597
  
598
  
599
  
600
  
601
  
602
  
603
  
604
  
605
  
606
  
607
  
608
  
609
  
610
  
611
  
612
  
613
  
614
  
615
  
616
  
617
  
618
  
619
  
620
  
621
  
622
  
623
  
624
  
625
  
626
  
627
  
628
  
629
  
630
  
631
  
632
  
633
  
634
  
635
  
636
  
637
  
638
  
639
  
640
  
641
  
642
  
643
  
644
  
645
  
646
  
647
  
648
  
649
  
650
  
651
  
652
  
653
  
654
  
655
  
656
  
657
  
658
  
659
  
660
  
661
  
662
  
663
  
664
  
665
  
666
  
667
  
668
  
669
  
670
  
671
  
672
  
673
  
674
  
675
  
676
  
677
  
678
  
679
  
680
  
681
  
682
  
683
  
684
  
685
  
686
  
687
  
688
  
689
  
690
  
691
  
692
  
693
  
694
  
695
  
696
  
697
  
698
  
699
  
700
  
701
  
702
  
703
  
704
  
705
  
706
  
707
  
708
  
709
  
710
  
711
  
712
  
713
  
714
  
715
  
716
  
717
  
718
  
719
  
720
  
721
  
722
  
723
  
724
  
725
  
726
  
727
  
728
  
729
  
730
  
731
  
732
  
733
  
734
  
735
  
736
  
737
  
738
  
739
  
740
  
741
  
742
  
743
  
744
  
745
  
746
  
747
  
748
  
749
  
750
  
751
  
752
  
753
  
754
  
755
  
756
  
757
  
758
  
759
  
760
  
761
  
762
  
763
  
764
  
765
  
766
  
767
  
768
  
769
  
770
  
771
  
772
  
773
  
774
  
775
  
776
  
777
  
778
  
779
  
780
  
781
  
782
  
783
  
784
  
785
  
786
  
787
  
788
  
789
  
790
  
791
  
792
  
793
  
794
  
795
  
796
  
797
  
798
  
799
  
800
  
801
  
802
  
803
  
804
  
805
  
806
  
807
  
808
  
809
  
810
  
811
  
812
  
813
  
814
  
815
  
816
  
817
  
818
  
819
  
820
  
821
  
822
  
823
  
824
  
825
  
826
  
827
  
828
  
829
  
830
  
831
  
832
  
833
  
834
  
835
  
836
  
837
  
838
  
839
  
840
  
841
  
842
  
843
  
844
  
845
  
846
  
847
  
848
  
849
  
850
  
851
  
852
  
853
  
854
  
855
  
856
  
857
  
858
  
859
  
860
  
861
  
862
  
863
  
864
  
865
  
866
  
867
  
868
  
869
  
870
  
871
  
872
  
873
  
874
  
875
  
876
  
877
  
878
  
879
  
880
  
881
  
882
  
883
  
884
  
885
  
886
  
887
  
888
  
889
  
890
  
891
  
892
  
893
  
894
  
895
  
896
  
897
  
898
  
899
  
900
  
901
  
902
  
903
  
904
  
905
  
906
  
907
  
908
  
909
  
910
  
911
  
912
  
913
  
914
  
915
  
916
  
917
  
918
  
919
  
920
  
921
  
922
  
923
  
924
  
925
  
926
  
927
  
928
  
929
  
930
  
931
  
932
  
933
  
934
  
935
  
936
  
937
  
938
  
939
  
940
  
941
  
942
  
943
  
944
  
945
  
946
  
947
  
948
  
949
  
950
  
951
  
952
  
953
  
954
  
955
  
956
  
957
  
958
  
959
  
960
  
961
  
962
  
963
  
964
  
965
  
966
  
967
  
968
  
969
  
970
  
971
  
972
  
973
  
974
  
975
  
976
  
977
  
978
  
979
  
980
  
981
  
982
  
983
  
984
  
985
  
986
  
987
  
988
  
989
  
990
  
991
  
992
  
993
  
994
  
995
  
996
  
997
  
998
  
999
  
1000
  
1001
  
1002
  
1003
  
1004
  
1005
  
1006
  
1007
  
1008
  
1009
  
1010
  
1011
  
1012
  
1013
  
1014
  
1015
  
1016
  
1017
  
1018
  
1019
  
1020
  
1021
  
1022
  
1023
  
1024
  
1025
  
1026
  
1027
  
1028
  
1029
  
1030
  
1031
  
1032
  
1033
  
1034
  
1035
  
1036
  
1037
  
1038
  
1039
  
1040
  
1041
  
1042
  
1043
  
1044
  
1045
  
1046
  
1047
  
1048
  
1049
  
1050
  
1051
  
1052
  
1053
  
1054
  
1055
  
1056
  
1057
  
1058
  
1059
  
1060
  
1061
  
1062
  
1063
  
1064
  
1065
  
1066
  
1067
  
1068
  
1069
  
1070
  
1071
  
1072
  
1073
  
1074
  
1075
  
1076
  
1077
  
1078
  
1079
  
1080
  
1081
  
1082
  
1083
  
1084
  
1085
  
1086
  
1087
  
1088
  
1089
  
1090
  
1091
  
1092
  
1093
  
1094
  
1095
  
1096
  
1097
  
1098
  
1099
  
1100
  
1101
  
1102
  
1103
  
1104
  
1105
  
1106
  
1107
  
1108
  
1109
  
1110
  
1111
  
1112
  
1113
  
1114
  
1115
  
1116
  
1117
  
1118
  
1119
  
1120
  
1121
  
1122
  
1123
  
1124
  
1125
  
1126
  
1127
  
1128
  
1129
  
1130
  
1131
  
1132
  
1133
  
1134
  
1135
  
1136
  
1137
  
1138
  
1139
  
1140
  
1141
  
1142
  
1143
  
1144
  
1145
  
1146
  
1147
  
1148
  
1149
  
1150
  
1151
  
1152
  
1153
  
1154
  
1155
  
1156
  
1157
  
1158
  
1159
  
1160
  
1161
  
1162
  
1163
  
1164
  
1165
  
1166
  
1167
  
1168
  
1169
  
1170
  
1171
  
1172
  
1173
  
1174
  
1175
  
1176
  
1177
  
1178
  
1179
  
1180
  
1181
  
1182
  
1183
  
1184
  
1185
  
1186
  
1187
  
1188
  
1189
  
1190
  
1191
  
1192
  
1193
  
1194
  
1195
  
1196
  
1197
  
1198
  
1199
  
1200
  
1201
  
1202
  
1203
  
1204
  
1205
  
1206
  
1207
  
1208
  
1209
  
1210
  
1211
  
1212
  
1213
  
1214
  
1215
  
1216
  
1217
  
1218
  
1219
  
1220
  
1221
  
1222
  
1223
  
1224
  
1225
  
1226
  
1227
  
1228
  
1229
  
1230
  
1231
  
1232
  
1233
  
1234
  
1235
  
1236
  
1237
  
1238
  
1239
  
1240
  
1241
  
1242
  
1243
  
1244
  
1245
  
1246
  
1247
  
1248
  
1249
  
1250
  
1251
  
1252
  
1253
  
1254
  
1255
  
1256
  
1257
  
1258
  
1259
  
1260
  
1261
  
1262
  
1263
  
1264
  
1265
  
1266
  
1267
  
1268
  
1269
  
1270
  
1271
  
1272
  
1273
  
1274
  
1275
  
1276
  
1277
  
1278
  
1279
  
1280
  
1281
  
1282
  
1283
  
1284
  
1285
  
1286
  
1287
  
1288
  
1289
  
1290
  
1291
  
1292
  
1293
  
1294
  
1295
  
1296
  
1297
  
1298
  
1299
  
1300
  
1301
  
1302
  
1303
  
1304
  
1305
  
1306
  
1307
  
1308
  
1309
  
1310
  
1311
  
1312
  
1313
  
1314
  
1315
  
1316
  
1317
  
1318
  
1319
  
1320
  
1321
  
1322
  
1323
  
1324
  
1325
  
1326
  
1327
  
1328
  
1329
  
1330
  
1331
  
1332
  
1333
  
1334
  
1335
  
1336
  
1337
  
1338
  
1339
  
1340
  
1341
  
1342
  
1343
  
1344
  
1345
  
1346
  
1347
  
1348
  
1349
  
1350
  
1351
  
1352
  
1353
  
1354
  
1355
  
1356
  
1357
  
1358
  
1359
  
1360
  
1361
  
1362
  
1363
  
1364
  
1365
  
1366
  
1367
  
1368
  
1369
  
1370
  
1371
  
1372
  
1373
  
1374
  
1375
  
1376
  
1377
  
1378
  
1379
  
1380
  
1381
  
1382
  
1383
  
1384
  
1385
  
1386
  
1387
  
1388
  
1389
  
1390
  
1391
  
1392
  
1393
  
1394
  
1395
  
1396
  
1397
  
1398
  
1399
  
1400
  
1401
  
1402
  
1403
  
1404
  
1405
  
1406
  
1407
  
1408
  
1409
  
1410
  
1411
  
1412
  
1413
  
1414
  
1415
  
1416
  
1417
  
1418
  
1419
  
1420
  
1421
  
1422
  
1423
  
1424
  
1425
  
1426
  
1427
  
1428
  
1429
  
1430
  
1431
  
1432
  
1433
  
1434
  
1435
  
1436
  
1437
  
1438
  
1439
  
1440
  
1441
  
1442
  
1443
  
1444
  
1445
  
1446
  
1447
  
1448
  
1449
  
1450
  
1451
  
1452
  
1453
  
1454
  
1455
  
1456
  
1457
  
1458
  
1459
  
1460
  
1461
  
1462
  
1463
  
1464
  
1465
  
1466
  
1467
  
1468
  
1469
  
1470
  
1471
  
1472
  
1473
  
1474
  
1475
  
1476
  
1477
  
1478
  
1479
  
1480
  
1481
  
1482
  
1483
  
1484
  
1485
  
1486
  
1487
  
1488
  
1489
  
1490
  
1491
  
1492
  
1493
  
1494
  
1495
  
1496
  
1497
  
1498
  
1499
  
1500
  
1501
  
1502
  
1503
  
1504
  
1505
  
1506
  
1507
  
1508
  
1509
  
1510
  
1511
  
1512
  
1513
  
1514
  
1515
  
1516
  
1517
  
1518
  
1519
  
1520
  
1521
  
1522
  
1523
  
1524
  
1525
  
1526
  
1527
  
1528
  
1529
  
1530
  
1531
  
1532
  
1533
  
1534
  
1535
  
1536
  
1537
  
1538
  
1539
  
1540
  
1541
  
1542
  
1543
  
1544
  
1545
  
1546
  
1547
  
1548
  
1549
  
1550
  
1551
  
1552
  
1553
  
1554
  
1555
  
1556
  
1557
  
1558
  
1559
  
1560
  
1561
  
1562
  
1563
  
1564
  
1565
  
1566
  
1567
  
1568
  
1569
  
1570
  
1571
  
1572
  
1573
  
1574
  
1575
  
1576
  
1577
  
1578
  
1579
  
1580
  
1581
  
1582
  
1583
  
1584
  
1585
  
1586
  
1587
  
1588
  
1589
  
1590
  
1591
  
1592
  
1593
  
1594
  
1595
  
1596
  
1597
  
1598
  
1599
  
1600
  
1601
  
1602
  
1603
  
1604
  
1605
  
1606
  
1607
  
1608
  
1609
  
1610
  
1611
  
1612
  
1613
  
1614
  
1615
  
1616
  
1617
  
1618
  
1619
  
1620
  
1621
  
1622
  
1623
  
1624
  
1625
  
1626
  
1627
  
1628
  
1629
  
1630
  
1631
  
1632
  
1633
  
1634
  
1635
  
1636
  
1637
  
1638
  
1639
  
1640
  
1641
  
1642
  
1643
  
1644
  
1645
  
1646
  
1647
  
1648
  
1649
  
1650
  
1651
  
1652
  
1653
  
1654
  
1655
  
1656
  
1657
  
1658
  
1659
  
1660
  
1661
  
1662
  
1663
  
1664
  
1665
  
1666
  
1667
  
1668
  
1669
  
1670
  
1671
  
1672
  
1673
  
1674
  
1675
  
1676
  
1677
  
1678
  
1679
  
1680
  
1681
  
1682
  
1683
  
1684
  
1685
  
1686
  
1687
  
1688
  
1689
  
1690
  
1691
  
1692
  
1693
  
1694
  
1695
  
1696
  
1697
  
1698
  
1699
  
1700
  
1701
  
1702
  
1703
  
1704
  
1705
  
1706
  
1707
  
1708
  
1709
  
1710
  
1711
  
1712
  
1713
  
1714
  
1715
  
1716
  
1717
  
1718
  
1719
  
1720
  
1721
  
1722
  
1723
  
1724
  
1725
  
1726
  
1727
  
1728
  
1729
  
1730
  
1731
  
1732
  
1733
  
1734
  
1735
  
1736
  
1737
  
1738
  
1739
  
1740
  
1741
  
1742
  
1743
  
1744
  
1745
  
1746
  
1747
  
1748
  
1749
  
1750
  
1751
  
1752
  
1753
  
1754
  
1755
  
1756
  
1757
  
1758
  
1759
  
1760
  
1761
  
1762
  
1763
  
1764
  
1765
  
1766
  
1767
  
1768
  
1769
  
1770
  
1771
  
1772
  
1773
  
1774
  
1775
  
1776
  
1777
  
1778
  
1779
  
1780
  
1781
  
1782
  
1783
  
1784
  
1785
  
1786
  
1787
  
1788
  
1789
  
1790
  
1791
  
1792
  
1793
  
1794
  
1795
  
1796
  
1797
  
1798
  
1799
  
1800
  
1801
  
1802
  
1803
  
1804
  
1805
  
1806
  
1807
  
1808
  
1809
  
1810
  
1811
  
1812
  
1813
  
1814
  
1815
  
1816
  
1817
  
1818
  
1819
  
1820
  
1821
  
1822
  
1823
  
1824
  
1825
  
1826
  
1827
  
1828
  
1829
  
1830
  
1831
  
1832
  
1833
  
1834
  
1835
  
1836
  
1837
  
1838
  
1839
  
1840
  
1841
  
1842
  
1843
  
1844
  
1845
  
1846
  
1847
  
1848
  
1849
  
1850
  
1851
  
1852
  
1853
  
1854
  
1855
  
1856
  
1857
  
1858
  
1859
  
1860
  
1861
  
1862
  
1863
  
1864
  
1865
  
1866
  
1867
  
1868
  
1869
  
1870
  
1871
  
1872
  
1873
  
1874
  
1875
  
1876
  
1877
  
1878
  
1879
  
1880
  
1881
  
1882
  
1883
  
1884
  
1885
  
1886
  
1887
  
1888
  
1889
  
1890
  
1891
  
1892
  
1893
  
1894
  
1895
  
1896
  
1897
  
1898
  
1899
  
1900
  
1901
  
1902
  
1903
  
1904
  
1905
  
1906
  
1907
  
1908
  
1909
  
1910
  
1911
  
1912
  
1913
  
1914
  
1915
  
1916
  
1917
  
1918
  
1919
  
1920
  
1921
  
1922
  
1923
  
1924
  
1925
  
1926
  
1927
  
1928
  
1929
  
1930
  
1931
  
1932
  
1933
  
1934
  
1935
  
1936
  
1937
  
1938
  
1939
  
1940
  
1941
  
1942
  
1943
  
1944
  
1945
  
1946
  
1947
  
1948
  
1949
  
1950
  
1951
  
1952
  
1953
  
1954
  
1955
  
1956
  
1957
  
1958
  
1959
  
1960
  
1961
  
1962
  
1963
  
1964
  
1965
  
1966
  
1967
  
1968
  
1969
  
1970
  
1971
  
1972
  
1973
  
1974
  
1975
  
1976
  
1977
  
1978
  
1979
  
1980
  
1981
  
1982
  
1983
  
1984
  
1985
  
1986
  
1987
  
1988
  
1989
  
1990
  
1991
  
1992
  
1993
  
1994
  
1995
  
1996
  
1997
  
1998
  
1999
  
2000
  
2001
  
2002
  
2003
  
2004
  
2005
  
2006
  
2007
  
2008
  
2009
  
2010
  
2011
  
2012
  
2013
  
2014
  
2015
  
2016
  
2017
  
2018
  
2019
  
2020
  
2021
  
2022
  
2023
  
2024
  
2025
  
2026
  
2027
  
2028
  
2029
  
2030
  
2031
  
2032
  
2033
  
2034
  
2035
  
2036
  
2037
  
2038
  
2039
  
2040
  
2041
  
2042
  
2043
  
2044
  
2045
  
2046
  
2047
  
2048
  
2049
  
2050
  
2051
  
2052
  
2053
  
2054
  
2055
  
2056
  
2057
  
2058
  
2059
  
2060
  
2061
  
2062
  
2063
  
2064
  
2065
  
2066
  
2067
  
2068
  
2069
  
2070
  
2071
  
2072
  
2073
  
2074
  
2075
  
2076
  
2077
  
2078
  
2079
  
2080
  
2081
  
2082
  
2083
  
2084
  
2085
  
2086
  
2087
  
2088
  
2089
  
2090
  
2091
  
2092
  
2093
  
2094
  
2095
  
2096
  
2097
  
2098
  
2099
  
2100
  
2101
  
2102
  
2103
  
2104
  
2105
  
2106
  
2107
  
2108
  
2109
  
2110
  
2111
  
2112
  
2113
  
2114
  
2115
  
2116
  
2117
  
2118
  
2119
  
2120
  
2121
  
2122
  
2123
  
2124
  
2125
  
2126
  
2127
  
2128
  
2129
  
2130
  
2131
  
2132
  
2133
  
2134
  
2135
  
2136
  
2137
  
2138
  
2139
  
2140
  
2141
  
2142
  
2143
  
2144
  
2145
  
2146
  
2147
  
2148
  
2149
  
2150
  
2151
  
2152
  
2153
  
2154
  
2155
  
2156
  
2157
  
2158
  
2159
  
2160
  
2161
  
2162
  
2163
  
2164
  
2165
  
2166
  
2167
  
2168
  
2169
  
2170
  
2171
  
2172
  
2173
  
2174
  
2175
  
2176
  
2177
  
2178
  
2179
  
2180
  
2181
  
2182
  
2183
  
2184
  
2185
  
2186
  
2187
  
2188
  
2189
  
2190
  
2191
  
2192
  
2193
  
2194
  
2195
  
2196
  
2197
  
2198
  
2199
  
2200
  
2201
  
2202
  
2203
  
2204
  
2205
  
2206
  
2207
  
2208
  
2209
  
2210
  
2211
  
2212
  
2213
  
2214
  
2215
  
2216
  
2217
  
2218
  
2219
  
2220
  
2221
  
2222
  
2223
  
2224
  
2225
  
2226
  
2227
  
2228
  
2229
  
2230
  
2231
  
2232
  
2233
  
2234
  
2235
  
2236
  
2237
  
2238
  
2239
  
2240
  
2241
  
2242
  
2243
  
2244
  
2245
  
2246
  
2247
  
2248
  
2249
  
2250
  
2251
  
2252
  
2253
  
2254
  
2255
  
2256
  
2257
  
2258
  
2259
  
2260
  
2261
  
2262
  
2263
  
2264
  
2265
  
2266
  
2267
  
2268
  
2269
  
2270
  
2271
  
2272
  
2273
  
2274
  
2275
  
2276
  
2277
  
2278
  
2279
  
2280
  
2281
  
2282
  
2283
  
2284
  
2285
  
2286
  
2287
  
2288
  
2289
  
2290
  
2291
  
2292
  
2293
  
2294
  
2295
  
2296
  
2297
  
2298
  
2299
  
2300
  
2301
  
2302
  
2303
  
2304
  
2305
  
2306
  
2307
  
2308
  
2309
  
2310
  
2311
  
2312
  
2313
  
2314
  
2315
  
2316
  
2317
  
2318
  
2319
  
2320
  
2321
  
2322
  
2323
  
2324
  
2325
  
2326
  
2327
  
2328
  
2329
  
2330
  
2331
  
2332
  
2333
  
2334
  
2335
  
2336
  
2337
  
2338
  
2339
  
2340
  
2341
  
2342
  
2343
  
2344
  
2345
  
2346
  
2347
  
2348
  
2349
  
2350
  
2351
  
2352
  
2353
  
2354
  
2355
  
2356
  
2357
  
2358
  
2359
  
2360
  
2361
  
2362
  
2363
  
2364
  
2365
  
2366
  
2367
  
2368
  
2369
  
2370
  
2371
  
2372
  
2373
  
2374
  
2375
  
2376
  
2377
  
2378
  
2379
  
2380
  
2381
  
2382
  
2383
  
2384
  
2385
  
2386
  
2387
  
2388
  
2389
  
2390
  
2391
  
2392
  
2393
  
2394
  
2395
  
2396
  
2397
  
2398
  
2399
  
2400
  
2401
  
2402
  
2403
  
2404
  
2405
  
2406
  
2407
  
2408
  
2409
  
2410
  
2411
  
2412
  
2413
  
2414
  
2415
  
2416
  
2417
  
2418
  
2419
  
2420
  
2421
  
2422
  
2423
  
2424
  
2425
  
2426
  
2427
  
2428
  
2429
  
2430
  
2431
  
2432
  
2433
  
2434
  
2435
  
2436
  
2437
  
2438
  
2439
  
2440
  
2441
  
2442
  
2443
  
2444
  
2445
  
2446
  
2447
  
2448
  
2449
  
2450
  
2451
  
2452
  
2453
  
2454
  
2455
  
2456
  
2457
  
2458
  
stest_true([["$Id: testsuite.in,v 1.123 1998/10/09 23:30:23 hubbe Exp $"]]) 
cond([[all_constants()->_verify_internals]], 
[[ 
  test_do(_verify_internals()) 
]]) 
test_eq(1e1,10.0) 
test_eq(1E1,10.0) 
test_eq(1e+1,10.0) 
test_eq(1.1e1,11.0) 
test_eq(1e-1,0.1) 
test_eq('\x20',32) 
test_eq("\x20","\040") 
test_eq('Å',"Å"[0]) 
test_eq(0x80000000-0x80000000, 0) 
test_eq(0xf0000000-0xf0000000, 0) 
test_eq(0x80000001-0x80000000, 1) 
test_eq(0x80000000-0x80000001,-1) 
test_true([[1.0e-40]]) 
test_eq([[#"foo 
bar"]],[["foo\nbar"]]) 
test_true([[stringp(#string "Makefile")]]) 
test_any([[class Bar { array(int) foo = ({}); }; class Foo { inherit Bar; array(int) foo = ({1}); }; return sizeof(Foo()->foo);]],1) 
 
test_false([[object_variablep(class X { int y; int z() { return 1; }}(),"foo")]]) 
test_false([[object_variablep(class X { int y; int z() { return 1; }}(),"z")]]) 
test_true([[object_variablep(class X { int y; int z() { return 1; }}(),"y")]]) 
 
test_any([[ int a,b; [a,b]=({1,2}); return a]],1) 
test_any([[ int a,b; [a,b]=({1,2}); return b]],2) 
test_any([[ int a,b; [ [a],b]=({ ({ 1 }) ,2}); return a]],1) 
test_any([[ int a,b; [ [a],b]=({ ({ 1 }) ,2}); return b]],2) 
test_compile_error([[ default ; ]]) 
test_compile_error([[ int a,b; [a,b]++; ]]) 
test_compile_error([[ 
array(int) x; 
 
string foo() 
{ 
 return "foo "+(array(string) x) * ","; 
} 
 
int main() 
{ 
  return 0; 
} 
]]) 
 
test_compile_eror(0()) 
test_compile_eror(1()) 
test_compile_eror(""()) 
test_compile_eror(([])()) 
test_compile_eror(([])()) 
test_any([[ class X { int y; class Z { void destroy() { y++; } } }; X x=X(); destruct(x->Z()); return x->y;]],1) 
test_eval_error([[ class Z { int destroy() { return 1/y; } }(); ]]) 
 
cond([[all_constants()->_debug]], 
[[ 
  test_do(_debug(_debug(0))) 
]]) 
test_do(_static_modules()) 
test_compile_any([[import Stdio; class x { string y() { read_file("foo"); } }]]) 
test_compile([[Stdio.File foo=Stdio.File();]]) 
test_compile([[  string|multiset(string) foo; 
  array(string) gazonk; 
  array(string) bar = indices(foo)-gazonk; 
]]) 
test_compile([[class { Stdio.File foo=Stdio.File(); }]]) 
test_compile_any([[void foo(Stdio.FILE f) {}]]) 
test_compile_any([[void foo(array(Stdio.FILE) f) {}]]) 
test_compile_any([[void foo(array(Stdio.FILE) f) {}]]) 
test_compile_any([[Stdio.File foo(array(Stdio.FILE) f) { return f[0]; }]]) 
test_compile([[Stdio.File foo=Stdio.FILE();]]) 
 
dnl this should really work... 
dnl test_compile_any([[void foo(int,string,...);]]) 
 
test_eval_error([[class X { int create() { create(); } }();]]) 
test_compile_error([[ int float; ]]) 
test_compile_error([[ int array; ]]) 
test_compile_error([[ int function; ]]) 
test_compile_error([[ int int; ]]) 
test_compile_error([[ int mapping; ]]) 
test_compile_error([[ int multiset; ]]) 
test_compile_error([[ int object; ]]) 
test_compile_error([[ int string; ]]) 
test_compile_error([[ int void; ]]) 
test_compile_error([[ int inline; ]]) 
test_compile_error([[ int local; ]]) 
test_compile_error([[ int nomask; ]]) 
test_compile_error([[ int predef; ]]) 
test_compile_error([[ int private; ]]) 
test_compile_error([[ int protected; ]]) 
test_compile_error([[ int public; ]]) 
test_compile_error([[ int static; ]]) 
test_compile_error([[ int final; ]]) 
test_compile_error([[ int do; ]]) 
test_compile_error([[ int else; ]]) 
test_compile_error([[ int return; ]]) 
test_compile_error([[ int constant; ]]) 
test_compile_error([[ int import; ]]) 
test_compile_error([[ int inherit; ]]) 
test_compile_error([[ int catch; ]]) 
test_compile_error([[ int gauge; ]]) 
test_compile_error([[ int lambda; ]]) 
test_compile_error([[ int sscanf; ]]) 
test_compile_error([[ int switch; ]]) 
test_compile_error([[ int typeof; ]]) 
test_compile_error([[ int break; ]]) 
test_compile_error([[ int case; ]]) 
test_compile_error([[ int continue; ]]) 
test_compile_error([[ int default; ]]) 
test_compile_error([[ int for; ]]) 
test_compile_error([[ int foreach; ]]) 
test_compile_error([[ int if; ]]) 
test_compile_error([[ int float = 0; ]]) 
test_eval_error([[ return 0.0[0]; ]]) 
test_eval_error([[ return 0[0]; ]]) 
test_compile_error([[constant x=class {}(); ]]) 
cond( [[ master()->resolv("Gmp")->mpz ]], 
[[ 
  test_compile_error([[object x = Gmp.mpz(17); constant y = x;]]) 
]]) 
test_any([[object(Stdio.File) f; f=Stdio.File(); return 1]],1) 
test_compile([[int t=gauge { string foo; };]]) 
test_compile_any([[class { object(Stdio.FILE) f; void create() { f=Stdio.FILE(); }}]]) 
test_eq([[compile_string("#define A(X) (X)\nint x() { return A \n\t(1); }")()->x()]],1) 
test_any([[class G { mapping t=([]); 
 class tO { void init(string name) { t[name]=this_object(); }} 
 class W { inherit tO; void create() { init("foo"); }} 
}; object x=G(); x->W(); return objectp(x->t->foo)]],1) 
test_eq([[cpp("#define FOO(X,Y) (X) (Y)\nFOO( (A),(B) )")]],"# 1 \"-\"\n\n( (A) ) ( (B) )") 
test_eq([[cpp("#define F 'F'\nF")]],"# 1 \"-\"\n\n'F'") 
test_eq([[cpp("#define MAX(X,Y) ((X)>(Y)?(X):(Y))\n#define MAX3(X,Y,Z) MAX(MAX(X,Y),Z)\nMAX3(1,2,3)")]],"# 1 \"-\"\n\n\n(( (( 1 )>( 2 )?( 1 ):( 2 )) )>( 3 )?( (( 1 )>( 2 )?( 1 ):( 2 )) ):( 3 ))") 
 
test_program([[class foo { program x() { return class {}; }}; class bar { inherit foo; program x() { return class {}; }} int a() { return foo()->x != bar()->x(); }]]) 
 
test_eq([[object_program(master())]],[[(program)"/master"]]) 
test_compile([[object("master") m = master();]]) 
test_any([[int x; x++; if(x) return x; return -1;]],1) 
test_any([[int x; if(x) return x; return -1;]],-1) 
test_any([[int x,y; if(x==y || x==1) return 2; return 0;]],2); 
test_any([[int x,y; if(x==y && x==0) return 2; return 0;]],2); 
test_any([[int x,y=1; if(x==y || x==1) return 2; return 0;]],0); 
test_any([[int x,y=1; if(x==y && x==0) return 2; return 0;]],0); 
 
test_eq([[ "\007" & "\023"]],"\003") 
test_eq([[ "\007" | "\023"]],"\027") 
test_eq([[ "\007" ^ "\023"]],"\024") 
 
test_compile_any([[ 
  class X { void hej() {} } 
  class Y { inherit X:banan; void hopp() { banan::hej(); } } 
]]) 
 
test_compile_any([[ 
  class X { static void hej() {} } 
  class Y { inherit X:banan; void hopp() { ::hej(); } } 
]]) 
 
test_compile_any([[ 
  class X { static void hej() {} } 
  class Y { inherit X; void hopp() { X::hej(); } } 
]]) 
 
test_compile_any([[ 
  class X { static void hej() {} } 
  class Y { public inherit X:banan; void hopp() { banan::hej(); } } 
]]) 
 
test_compile_any([[ 
  class X { static void hej() {} } 
  class Y { inherit X:banan; void hopp() { banan::hej(); } } 
]]) 
 
 
// Testing the 'inline' keyword 
test_program([[class foo { inline int c() { return time(); } int d() { return c(); } }; class bar { inherit foo; int c() { return 0; } } int a() { return bar()->d(); }]],0) 
 
test_compile_any([[ 
  class top 
  { 
     class the_class 
     { 
     } 
  } 
   
  class inherit_top 
  { 
     inherit top:top; 
   
     constant top_the_class=top::the_class; 
   
     class the_other_class 
     { 
        inherit top_the_class; 
     } 
  } 
]]) 
 
// Testing __INIT 
test_any([[ 
  class X { int x = 1; }; 
  class Y { int y = 2; }; 
  class Z { inherit X; inherit Y; int z = 4; }; 
  object zz = Z(); 
  return zz->x + zz->y + zz->z; 
]], 7) 
 
test_any([[ 
class X { 
 static string f() { return "p"; } 
 static class gazonk { void create() { f(); }}; 
  static class g { object e() { return gazonk(); }}; 
 void create() { g()->e(); }}; return objectp(X()); ]],1) 
test_any([[class A { protected int x=1; }; class B { inherit A; int foo() { return A::x; }}; return A()->x==B()->x && B()->foo()==A()->x;]],1) 
test_any([[class C { int q() { return p(); } int p() { return 17; }}; return C()->q();]],17) 
test_any([[class C1 { 
 class D { string id() { return "foo"; } }; 
 class Y { program YinD() { return D; }} }; 
 class C2 { inherit C1; class D { string id() { return "bar"; } } }; 
 return C2()->Y()->YinD()()->id()]],"bar") 
test_any([[object o=class foo{int c;class bar{void create(){c++;};}}(); o->bar(); return o->c;]],1) 
test_do([[add_constant("GURKA2",class foo { int c; class bar{void create() {c+=17;}}}()); ]]) 
test_any([[class x { inherit GURKA2.bar; }(); return GURKA2->c;]],17) 
test_any([[class x { inherit GURKA2.bar; }(); return GURKA2->c;]],34) 
 
test_do([[add_constant("GURKA2",class foo { int c; class bar{void create() { class sune { void create() {c+=17;}}(); }}}()); ]]) 
test_any([[class x { inherit GURKA2.bar; }(); return GURKA2->c;]],17) 
test_any([[class x { inherit GURKA2.bar; }(); return GURKA2->c;]],34) 
test_do([[add_constant("GURKA2");]]); 
 
test_eq(class { static int foo=17; }()->foo,0) 
test_eval_error(class c { static int foo=17; }()->foo=18;) 
test_equal( [[ ({ (["foo":"bar"]), (<"foo">), ([]) })->foo ]], [[ ({"bar",1,0}) ]]) 
test_any([[mixed a=({([]),0}); a[1]=a; return a->foo[0];]],0) 
test_eval_error([[return column(({0}),"foo");]]) 
 
test_any([[ 
class A { constant a=0; int foo() { return a; } }; 
class B { inherit A; constant a=1; }; 
return B()->foo(); ]], 1) 
 
test_any([[ 
class p1 { int foo() { return 1; }}; 
class p2 { int foo() { return 3; }}; 
class c1 { inherit p1; inherit p2; int foo() { return p1::foo()+p2::foo(); }}; 
class c2 { inherit c1; }; return c2()->foo();]],4) 
 
test_any([[ 
class p1 { int foo() { return 1; } }; 
class p2 { int foo() { return 2; } }; 
class c1 { inherit p1; inherit p2; }; 
return c1()->foo();]],2) 
 
test_any([[class foo { int x=random(100); int `<(object o) { return x < o->x; } }; object *o=Array.map(allocate(100),foo); sort(o); for(int e=1;e<100;e++) if(o[e-1]->x > o[e]->x) return e; return -1;]],-1) 
test_compile_error([[void foo() { 1++; }]]) 
test_compile_error([[void foo() { return destruct(this_object()); }]]) 
test_any([[class foo { constant x=17; }; class bar { inherit foo; constant x=18; }; return bar()->x;]],18) 
test_program([[inline string foo(string s){ while(s[0] == ' ' || s[0] == '\t') s = s[1..]; return(s); } string a() { return foo("   bar"); }]]) 
test_true([[lambda(function f) {return 1;}(object_program(this_object()));]]) 
test_eq([[class c { int `()(){ return 4711; } }()(); ]],4711) 
teste_eval_error(mixed foo=({}); sort(@foo); ) 
test_compile_error([[int foo() { return 1} ; constant foo=(["foo":foo]); return foo->foo();]]) 
test_compile_error([[class T{void p(object e,object f){lambda::create(f);}}]]) 
test_eval_error(mixed *foo=({}); return mkmapping(foo,({1})); ) 
test_true(time()) 
test_true(time(1)) 
test_compile_error([[mapping (string:array(string:string)) foo=([]); ]]) 
test_compile_error([[int a() { switch(random(2)) { case 3: if(random(2)) { case 0: return 1; } else { case 1: return 2; } } }]]) 
 
test_true(encode_value(0)) 
test_true(encode_value(0)[0]=='\266') 
define(test_encode, [[ test_equal($1, decode_value(encode_value($1))) ]]) 
test_eq(replace("foobar","","X"),"fXoXoXbXaXr") 
test_encode(0) 
test_encode("") 
test_encode(0.0) 
test_encode(1.0) 
test_encode(-1.0) 
test_encode(12.0) 
test_encode(100000.0) 
test_encode(3.14159265) 
test_encode(0.000001) 
test_encode(({})) 
test_encode(([])) 
test_encode("foobar") 
test_encode((<>)) 
test_eq(decode_value("\210\201"),1) 
test_eq(decode_value("\210\011\001"),-1) 
test_eq(decode_value("\206\200"),"")) 
test_equal(decode_value("\200\200"),({})) 
test_equal(decode_value("\206\206\146\157\157\142\141\162"),"foobar") 
test_any([[mixed a=({0}); a[0]=a; return equal(a, decode_value(encode_value(a)));]], 1) 
test_any([[ int e; for(e=0;e<100000;e+=1+(e>>4)) if(decode_value(encode_value(e))!=e) return e; return -1;]], -1) 
test_any([[ int e; for(e=0;e<100000;e+=1+(e>>4)) if(decode_value(encode_value(-e))!=-e) return e; return -1;]], -1) 
 
test_any([[mixed s="foo"; return s++;]],"foo") 
test_any([[mixed s="foo"; s++; return s;]],"foo1") 
test_any([[mixed s="foo"; return ++s;]],"foo1") 
test_any([[float p=2.0; return p--;]],2.0); 
test_any([[float p=2.0; p--; return p;]],1.0) 
test_any([[float p=2.0; return --p;]],1.0) 
 
test_compile_error(int foo() { LJjjjjJJJ ; }) 
test_true(clone(class c { constant i=1; })->i) 
test_true(clone(class c { constant i=0; mixed `->(string s) { if(s=="i") return 1; }})->i) 
test_true(clone(class c { constant i=1; mixed `->(string s) { return 0; }})["i"]) 
test_true(clone(class c { constant i=0; mixed `[](string s) { if(s=="i") return 1; }})["i"]) 
test_true(clone(class c { mixed `[]=(mixed a, mixed b) { if(a!=b) throw(1); }})[1]=1) 
test_true(clone(class c { mixed `->=(mixed a, mixed b) { if(a!=b) throw(1); }})->i="i") 
 
test_compile_any(class A {}; class B { inherit A; }) 
 
test_true(mappingp(_memory_usage())) 
test_true(_refs("")); 
test_true(_refs(({}))); 
test_true(_refs(([]))); 
test_true(_refs(this_object())) 
test_true(objectp( _next(this_object()) || _prev(this_object()))) 
test_true(arrayp( _next(({})) || _prev(({})))) 
test_any(object o=this_object(); while(o=_next(o))) 
test_any(object o=this_object(); while(o=_prev(o))) 
 
test_any([[object(Stdio.File) o=Stdio.File(); return objectp(o);]],1) 
test_any([[object o=Regexp("foo"); return objectp(o);]],1) 
test_any([[object o=Regexp("foo"); return object_program(o);]],Regexp) 
test_any([[class Test {}; object(Test) o=Test(); return object_program(o);]],Test) 
test_define_program(test,[[constant foo = 1; int a() { return foo; }]]) 
test_true(new(test)->a()) 
test_program(inherit test;) 
test_program(inherit test; int a() { return foo; } ) 
test_define_program(test,[[class TEST { int a() { return 1; } }]]) 
test_program(inherit test; inherit TEST; ) 
 
test_compile_error(class c { object(Stdio.File) foo=class {} ();}) 
test_compile_error(class c { object(Stdio.File) foo=class {} ();}) 
test_compile_error(class c { object(Stdio.File) foo=class {} ();}) 
test_compile_error(class c { object(Stdio.File) foo=class foobar {} ();}) 
test_do(class c { object foo; object(Regexp) bar=foo; }) 
test_do(class c { object(Stdio.File) foo; object bar=foo; }) 
test_any(if(int i=1) return i; return 0;,1) 
test_compile(for(int i=0;i<100;i++) return 0;) 
test_compile(foreach(({}),mixed i){}) 
test_compile(sscanf("","",mixed foo)) 
test_compile_error(sscanf("","",float)) 
test_compile_error(sscanf("",float)) 
 
// ++ 
test_any([[int e; e++; return e;]],1) 
test_any([[int e; ++e; return e;]],1) 
test_any([[int e; return e++;]],0) 
test_any([[int e; return ++e;]],1) 
test_any([[int e; if(e++) return 0; return e;]],1) 
test_any([[string e=""; e++; return e;]],"1") 
 
// -- 
test_any([[int e; e--; return e;]],-1) 
test_any([[int e; --e; return e;]],-1) 
test_any([[int e; return e--;]],0) 
test_any([[int e; return --e;]],-1) 
test_any([[int e; if(e--) return 0; return e;]],-1) 
 
test_compile_error_low(master()->add_precompiled_program(\"/test\",compile_string(\"int foo() { return 17; }\",\"62\"))) 
 
test_any([[function f=random_seed; int t; foreach(allocate(1),t) f(t); return 1;]],1) 
test_compile([[while(0)if(0)continue;else;]]) 
test_program([[int b=1,c; int a() { c=b+2; return c==3; }]]) 
test_true([[ ("foobar"/"o") & ({ "foo" }) ]]) 
test_any([[ array a="foo bar"/" "; return sizeof(a & ({"foo"}))]],1) 
 
// glob 
test_false(glob("foo","bar")) 
test_true(glob("foo","foo")) 
test_true(glob("f?o","foo")) 
test_true(glob("f??","foo")) 
test_true(glob("?o?","foo")) 
test_true(glob("f*","foo")) 
test_true(glob("*o","foo")) 
test_true(glob("*<<<*","<<<")) 
test_true(glob("*<<<*","<<<foo")) 
test_false(glob("*f","foo")) 
test_false(glob("o*","foo")) 
test_false(glob("?f?","foo")) 
test_equal([[glob("?f?",({"ff","ffff","off","fff",""}))]],[[({"off","fff"})]]) 
test_equal([[glob("foo*bar",({"foobar","foobargazonk","","foofoobar","fobar","fooar"}))]],[[({"foobar","foofoobar"})]]) 
 
// localtime 
cond([[all_constants()->localtime]], 
[[ 
test_true(mappingp(localtime(0))) 
]]) 
 
cond([[all_constants()->mktime]], 
[[ 
  test_true([[mktime( ([ 
  "sec":58, 
  "isdst":1, 
  "year":98, 
  "mon":3, 
  "mday":26, 
  "hour":1, 
  "min":51 
]))]]) 
 
  test_eq([[mktime(58,51,1,26,3,98,1,0)]],[[mktime( ([ 
  "sec":58, 
  "isdst":1, 
  "year":98, 
  "mon":3, 
  "mday":26, 
  "hour":1, 
  "min":51, 
  "timezone":0, 
]) ) ]]) 
 
]]) 
 
cond([[all_constants()->localtime && all_constants()->mktime]], 
[[ 
  test_any([[int x=time(); return mktime(localtime(x)) == x;]], 1) 
  test_any([[int x=time(); for(int y=0;y<100;y++) if(mktime(localtime(x+y)) != x+y) return x+y; return 0;]], 0) 
]]) 
 
cond([[all_constants()->_verify_internals]], 
[[ 
  test_do(_verify_internals()) 
]]) 
 
// sort 
test_equal(sort(({1,3,2,4})),({1,2,3,4})) 
test_equal(sort(({4,3,2,1})),({1,2,3,4})) 
test_equal([[lambda() {string *a=({1,2,3,4}); sort(({4,3,2,1}),a); return a; }()]],[[({4,3,2,1})]] ) 
test_equal([[lambda() {string *a=({1,2,3,4}),*b=a+({}); sort(({4,3,2,1}),a,b); return b; }()]],[[({4,3,2,1})]] ) 
 
cond([[all_constants()->thread_create]], 
[[ 
// thread_create 
  test_do(thread_create(lambda() { })) 
 
// /precompiled/mutex 
  test_true(Thread.Mutex()) 
  test_do(add_constant("_tmp_mutex",Thread.Mutex())) 
  test_true(_tmp_mutex->lock()) 
  test_true(_tmp_mutex->lock()) 
  test_true(_tmp_mutex->trylock()) 
  test_true(_tmp_mutex->trylock()) 
  test_do(add_constant("_tmp_mutex_lock",_tmp_mutex->lock())) 
  test_true(catch(_tmp_mutex->trylock())) 
  test_do(add_constant("_tmp_mutex_lock")) 
  test_true(_tmp_mutex->trylock()) 
  test_do(add_constant("_tmp_mutex")) 
  test_any([[ object m = Thread.Mutex(); object k = m->lock(); thread_create(lambda(object k){ sleep(10); catch { destruct(k); }; }, k);if (catch{m->lock(); return 0;}) { return 1; } return 0; ]],1) 
  test_any([[ mixed *data=({0,Thread.Mutex(),Thread.Mutex(),0}); data[3]=data[2]->lock(); thread_create(lambda(mixed *data) {object o=data[1]->lock(); destruct(data[3]); sleep(10); data[0]=1; destruct(o);  },data); object l=data[2]->lock(1); object ll=data[1]->lock(); return data[0]; ]],1) 
  test_any([[ 
mixed *data=({1, Thread.Mutex(), Thread.Condition(), 0}); 
for(int e=0;e<3;e++) { data[3]++; thread_create(lambda(mixed *data) { 
  for(int e=0;e<1000;e++) { object o=data[1]->lock(); data[0]*=2; 
    for(int d=0;d<5;d++) { data[0]--; data[0]*=2; } data[0]--; destruct(o); } 
   data[3]--; data[2]->signal();}, data);} 
 while(data[3]) data[2]->wait(); return data[0];]],1) 
 
// /precompiled/condition 
  test_true(Thread.Condition()) 
  test_do(Thread.Condition()->signal()) 
  test_do(Thread.Condition()->broadcast()) 
 
  test_true(objectp(clone(Thread.Fifo))) 
  test_true(objectp(clone(Thread.Queue))) 
 
  test_any([[object o=Thread.Queue(); thread_create(lambda(object f) { for(int e=0;e<10000;e++) f->write(random(4711)); f->write(-1); },o); int tmp=0; while(o->read() != -1) tmp++; return tmp;]],10000) 
  test_any([[object o=Thread.Fifo(); thread_create(lambda(object f) { for(int e=0;e<10000;e++) f->write(random(4711)); f->write(-1); },o); int tmp=0; while(o->read() != -1) tmp++; return tmp;]],10000) 
]]) 
 
 
  test_true(Getopt.find_option(({"","--foo"}),"p","foo")) 
  test_eq(Getopt.find_option(({"","--foo=bar"}),"p","foo",0,0),"bar") 
  test_eq(Getopt.find_option(({"","--foo","bar"}),"p","foo",0,0),"bar") 
  test_eq(Getopt.find_option(({"","--","--foo=bar"}),"p","foo",0,0),0) 
 
  test_true(Getopt.find_option(({"","-p"}),"p","foo")) 
  test_eq(Getopt.find_option(({"","-pbar"}),"p","foo",0,0),"bar") 
  test_eq(Getopt.find_option(({"","-p","bar"}),"p","foo",0,0),"bar") 
  test_eq(Getopt.find_option(({"","--","--p","bar"}),"p","foo",0,0),0) 
 
  test_equal(Getopt.get_args(({"",0,0,"sune","--","-foo"})),({"","sune","-foo"})) 
 
  test_true(objectp(clone(String.String_buffer))) 
  test_do(clone(String.String_buffer)->append("foo")) 
  test_do(add_constant("Flurp",clone(String.String_buffer))) 
  test_do(Flurp->append("test")) 
  test_do(Flurp->append("test")) 
  test_eq((string)Flurp,"testtest") 
  test_do(add_constant("Flurp")) 
 
  test_eq(String.strmult("foo",4),"foofoofoofoo") 
 
// m_delete 
test_equal(([1:1]),m_delete(a(),0)) 
test_equal(([1:1]),m_delete(([1:1,0:3]),0)) 
test_any(mapping a=([1:1]); return a==m_delete(a,1),1) 
test_any([[mapping m=([]); m[1]++; return m[1];]],1) 
test_any([[mapping m=([1:1]); m[1]++; return m[1];]],2) 
test_any([[mapping m=([]); m[1]++; m[1]++; return m[1];]],2) 
 
// multiset tests 
 
test_any([[multiset m=(<>);int e; 
  for(e=0;e<1000;e++) m[e]=1; 
  for(e=0;e<1000;e++) if(!m[e]) return e; 
  return -1; 
]],-1) 
 
test_any([[multiset m=(<>);int e; 
  for(e=0;e<1000;e++) m[e]++; 
  for(e=0;e<1000;e++) if(!m[e]) return e; 
  return -1; 
]],-1) 
 
test_any([[multiset m=(<>);int e; 
  for(e=0;e<1000;e++) m[e]=1; 
  for(e=999;e>=0;e--) if(!m[e]) return e; 
  return -1; 
]],-1) 
 
test_any([[multiset m=(<>);int e; 
  for(e=999;e>=0;e--) m[e]=1; 
  for(e=0;e<1000;e++) if(!m[e]) return e; 
  return -1; 
]],-1) 
 
test_any([[multiset m=(<>);int e; 
  for(e=999;e>=0;e--) m[e]=1; 
  for(e=999;e>=0;e--) if(!m[e]) return e; 
  return -1; 
]],-1) 
 
test_any([[multiset m=(<>);int e; 
  for(e=0;e<1000;e++) m[reverse(e)]=1; 
  for(e=0;e<1000;e++) if(!m[reverse(e)]) return e; 
  return -1; 
]],-1) 
 
test_any([[multiset m=(<>);int e; 
  for(e=999;e>=0;e--) m[reverse(e)]=1; 
  for(e=0;e<1000;e++) if(!m[reverse(e)]) return e; 
  return -1; 
]],-1) 
 
test_any([[multiset m=(<>);int e; 
  for(e=0;e<1000;e++) m[reverse(e)]=1; 
  for(e=0;e<1000;e++) m[reverse(e)]=0; 
  return sizeof(m); 
]],0) 
 
test_any([[multiset m=(<>);int e; 
  for(e=0;e<1000;e++) m[reverse(e)]=1; 
  for(e=0;e<1000;e+=2) m[reverse(e)]=0; 
  for(e=0;e<1000;e+=2) if(m[reverse(e)]) return e; 
  for(e=1;e<1000;e+=2) if(!m[reverse(e)]) return e; 
  return -1; 
]],-1) 
 
 
test_any([[multiset m=(<>);int e; 
  for(e=0;e<1000;e++) m[reverse(e)]=1; 
  for(e=0;e<1000;e++) m[reverse(e)]++; 
  for(e=0;e<1000;e++) if(m[reverse(e)]!=1) return e; 
  return -1; 
]],-1) 
 
 
test_any([[multiset m=(<>);int e; 
  mixed a; 
  a=allocate(1000); 
  for(e=0;e<1000;e++) 
  { 
    m[reverse(e)]=1; 
    a[e]=reverse(e); 
  } 
  add_constant("mtest_m",m); 
  add_constant("mtest_i",a); 
  return 1; 
]],1) 
 
test_eq([[sizeof(mtest_m)]],sizeof(mtest_i)) 
test_equal(Array.sort_array(indices(mtest_m)),Array.sort_array(mtest_i)) 
test_equal(mtest_m,copy_value(mtest_m)) 
 
test_any([[multiset m=(<>);int e; 
  mixed a; 
  a=allocate(100); 
  for(e=0;e<100;e++) 
  { 
    m[reverse(e-50)]=1; 
    a[e]=reverse(e-50); 
    if(sizeof(m)!=e+1) return e; 
  } 
  add_constant("mtest_m2",m); 
  add_constant("mtest_i2",a); 
  return -1; 
]],-1) 
 
test_eq([[sizeof(mtest_m2)]],sizeof(mtest_i2)) 
test_any([[int e;multiset q=(<>),p=(<>); for(e=0;e<1000;e++) { p[reverse(e)]=1; q+=(<reverse(e)>); if(!equal(sort(indices(p)),sort(indices(q)))) return 0; } return 1;]],1) 
 
test_equal(sort(indices(mtest_m|mtest_m2)),sort(mtest_i|mtest_i2)) 
test_equal(sort(indices(mtest_m&mtest_m2)),sort(mtest_i&mtest_i2)) 
test_equal(sort(indices(mtest_m-mtest_m2)),sort(mtest_i-mtest_i2)) 
test_equal(sort(indices(mtest_m^mtest_m2)),sort(mtest_i^mtest_i2)) 
test_equal(sort(indices(mtest_m2|mtest_m)),sort(mtest_i2|mtest_i)) 
test_equal(sort(indices(mtest_m2&mtest_m)),sort(mtest_i2&mtest_i)) 
test_equal(sort(indices(mtest_m2-mtest_m)),sort(mtest_i2-mtest_i)) 
test_equal(sort(indices(mtest_m2^mtest_m)),sort(mtest_i2^mtest_i)) 
 
test_do(add_constant("mtest_m"); add_constant("mtest_i"); ) 
test_do(add_constant("mtest_m2"); add_constant("mtest_i2"); ) 
 
define([[MTEST]],[[test_equal([[mkmultiset(indices(allocate($1)))]],[[mkmultiset(reverse(indices(allocate($1))))]])]]) 
 
MTEST(0) 
MTEST(1) 
MTEST(2) 
MTEST(3) 
MTEST(5) 
MTEST(8) 
MTEST(13) 
MTEST(21) 
MTEST(34) 
MTEST(55) 
 
define([[MTEST]]) 
 
// mapping tests 
 
test_any([[mapping m=([]);int e; 
  for(e=0;e<1000;e++) m[e]=e; 
  for(e=0;e<1000;e++) if(m[e]!=e) return 0; 
  return 1; 
]],1) 
 
test_any([[mapping m=([]);int e; 
  for(e=0;e<1000;e++) m[e]=e; 
  for(e=999;e>=0;e--) if(m[e]!=e) return 0; 
  return 1; 
]],1) 
 
 
test_any([[mapping m=([]);int e; 
  for(e=999;e>=0;e--) m[e]=e; 
  for(e=0;e<1000;e++) if(m[e]!=e) return 0; 
  return 1; 
]],1) 
 
test_any([[mapping m=([]);int e; 
  for(e=999;e>=0;e--) m[e]=e; 
  for(e=999;e>=0;e--) if(m[e]!=e) return 0; 
  return 1; 
]],1) 
 
 
test_any([[mapping m=([]);int e; 
  for(e=0;e<1000;e++) m[reverse(e)]=e; 
  for(e=0;e<1000;e++) if(m[reverse(e)]!=e) return 0; 
  return 1; 
]],1) 
 
 
test_any([[mapping m=([]);int e; 
  for(e=999;e>=0;e--) m[reverse(e)]=e; 
  for(e=0;e<1000;e++) if(m[reverse(e)]!=e) return 0; 
  return 1; 
]],1) 
 
 
test_any([[mapping m=([]);int e; 
  for(e=0;e<1000;e++) m[reverse(e)]=e; 
  for(e=0;e<1000;e++) m_delete(m,reverse(e)); 
  return sizeof(m); 
]],0) 
 
test_any([[mapping m=([]);int e; 
  for(e=0;e<1000;e++) m[reverse(e)]=e; 
  for(e=0;e<1000;e+=2) m_delete(m,reverse(e)); 
  for(e=0;e<1000;e+=2) if(m[reverse(e)]) return 0; 
  for(e=1;e<1000;e+=2) if(m[reverse(e)]!=e) return 0; 
  return 1; 
]],1) 
 
test_any([[mapping m=([]);int e; 
  for(e=0;e<1000;e++) m[reverse(e)]=e; 
  for(e=0;e<1000;e++) m[reverse(e)]++; 
  for(e=0;e<1000;e++) if(m[reverse(e)]!=e+1) return 0; 
  return 1; 
]],1) 
 
test_any([[mapping m=([]);int e; 
  mixed a,b; 
  a=allocate(1000); 
  b=allocate(1000); 
  for(e=0;e<1000;e++) 
  { 
    m[reverse(e)]=e; 
    a[e]=reverse(e); 
    b[e]=e; 
  } 
  add_constant("mtest_m",m); 
  add_constant("mtest_i",a); 
  add_constant("mtest_v",b); 
  return 1; 
]],1) 
 
 
test_eq([[sizeof(mtest_m)]],sizeof(mtest_i)) 
test_equal(Array.sort_array(indices(mtest_m)),Array.sort_array(mtest_i)) 
test_equal(Array.sort_array(values(mtest_m)),Array.sort_array(mtest_v)) 
test_equal(mtest_m,copy_value(mtest_m)) 
test_any([[int e; for(e=0;e<1000;e++) if(!equal(mtest_m[mtest_i[e] ],mtest_v[e])) return 0; return 1;]],1) 
 
 
test_any([[mapping m=([]);int e; 
  mixed a,b; 
  a=allocate(100); 
  b=allocate(100); 
  for(e=0;e<100;e++) 
  { 
    m[reverse(e-50)]=e-50; 
    a[e]=reverse(e-50); 
    b[e]=reverse(e-50); 
  } 
  add_constant("mtest_m2",m); 
  add_constant("mtest_i2",a); 
  add_constant("mtest_v2",b); 
  return 1; 
]],1) 
 
test_any([[int e;mapping q=([]),p=([]); for(e=0;e<1000;e++) { p[reverse(e)]=e; q+=([reverse(e):e]); if(!equal(sort(indices(p)),sort(indices(q)))) return 0; } return 1;]],1) 
test_any([[mapping m=([]); m+=(["foo":"bar"]); m+=(["bar":"foo"]); m+=(["foo":"foo"]); if(sizeof(m)==3) return 1; return m["foo"]=="foo" && m["bar"]=="foo"]],1) 
 
test_equal(sort(indices(mtest_m|mtest_m2)),sort(mtest_i|mtest_i2)) 
test_equal(sort(indices(mtest_m&mtest_m2)),sort(mtest_i&mtest_i2)) 
test_equal(sort(indices(mtest_m-mtest_m2)),sort(mtest_i-mtest_i2)) 
test_equal(sort(indices(mtest_m^mtest_m2)),sort(mtest_i^mtest_i2)) 
test_equal(sort(indices(mtest_m2|mtest_m)),sort(mtest_i2|mtest_i)) 
test_equal(sort(indices(mtest_m2&mtest_m)),sort(mtest_i2&mtest_i)) 
test_equal(sort(indices(mtest_m2-mtest_m)),sort(mtest_i2-mtest_i)) 
test_equal(sort(indices(mtest_m2^mtest_m)),sort(mtest_i2^mtest_i)) 
 
test_do(add_constant("mtest_m"); add_constant("mtest_i"); add_constant("mtest_v");) 
test_do(add_constant("mtest_m2"); add_constant("mtest_i2"); add_constant("mtest_v2");) 
 
define([[MTEST]],[[test_equal([[mkmapping(indices(allocate($1)),reverse(indices(allocate($1))))]],[[mkmapping(reverse(indices(allocate($1))),indices(allocate($1)))]])]]) 
 
MTEST(0) 
MTEST(1) 
MTEST(2) 
MTEST(3) 
MTEST(5) 
MTEST(8) 
MTEST(13) 
MTEST(21) 
MTEST(34) 
MTEST(55) 
 
define([[MTEST]]) 
 
test_equal([[ `+( ([1:2]) )]],[[ ([1:2]) ]]) 
test_false( `+( ([1:2]) ) == ([1:2]) ) 
test_equal([[ `+( ([1:2]), ([1:2])  )]],[[ ([1:2]) ]]) 
test_equal([[ `+( ([1:2]), ([1:2]), ([2:3,4:5])  )]],[[ ([1:2,2:3,4:5]) ]]) 
test_equal([[ `+( ([1:2]), ([1:2]), ([2:3,4:5]), ([6:7,1:2])  )]],[[ ([1:2,2:3,4:5,6:7]) ]]) 
test_equal([[ `+( ([1:2]), ([1:2]), ([2:3,4:5]), ([6:7,1:2]),([8:9])  )]],[[ ([1:2,2:3,4:5,6:7,8:9]) ]] ) 
 
test_any([[mapping m=([1:2,3:2]); return search(m,2,search(m,2))!=-1;]],1) 
 
// rows 
test_equal([[rows(({1,2,3,4,5,6,7,8,9}),({6,7,2}))]],[[({7,8,3})]]) 
test_equal([[rows(({1,2,3,4,5,6,7,8,9}),({0,4,1}))]],[[({1,5,2})]]) 
test_equal([[rows(({1,2,3,4,5,6,7,8,9}),({8,3,5}))]],[[({9,4,6})]]) 
 
// column 
test_equal([[column(({({1,2,3}),({5,6,7}),({8,9,0})}),0)]],[[({1,5,8})]]) 
test_equal([[column(({({1,2,3}),({5,6,7}),({8,9,0})}),1)]],[[({2,6,9})]]) 
test_equal([[column(({({1,2,3}),({5,6,7}),({8,9,0})}),2)]],[[({3,7,0})]]) 
 
 
// gc 
ifefun(gc, 
[[ 
  test_true(intp(gc())); 
  test_any([[ array a=({0}); a[0]=a; gc(); a=0; return gc() > 0; ]],1); 
  test_any([[object o=class c {object o;}(); o->o=o; gc(); o=0; return gc() > 0; ]],1); 
  test_any([[object o=class c {object o;}(); o->o=o; gc(); o=0; return gc() > 0; ]],1); 
  test_any([[mapping m=([]); m[m]=m; gc(); m=0; return gc() > 0; ]],1); 
  test_any([[multiset m=(<>); m[m]=1; gc(); m=0; return gc() > 0; ]],1); 
]]) 
 
cond([[all_constants()->_verify_internals]], 
[[ 
  test_do(_verify_internals()) 
]]) 
 
test_eq("\377"[0],255) 
test_do(add_constant("foo",clone(class c {int i;}))) 
test_eq(foo->i,0) 
test_do(foo->i=17) 
test_eq(foo->i,17) 
test_do(add_constant("foo")); 
test_do(add_constant("foo",clone(class c {int *i=({0});}))) 
test_eq(foo->i[0],0) 
test_do(foo->i[0]=17) 
test_eq(foo->i[0],17) 
test_do(add_constant("foo")); 
 
// signum, signame 
test_true(intp(signum("SIGKILL"))) 
 
// kill, signal, getpid 
test_true(intp(getpid())) 
cond([[all_constants()->kill && (cpp("__NT__")/"\n")[1]=="__NT__" ]], 
[[ 
  test_do(signal(signum("SIGFPE"),lambda() { add_constant("AFJLLAF",17); })) 
  test_do(kill(getpid(),signum("SIGFPE"))) 
  test_do(sleep(2)) 
  test_eq(AFJLLAF,17) 
  test_do(add_constant("AFJLLAF")) 
  test_do(signal(signum("SIGFPE",0))) 
  test_do(signal(signum("SIGFPE"))) 
]]) 
 
// typeof 
test_eq(typeof(1),"int") 
test_eq(typeof(""),"string") 
test_eq(typeof(""[0]),"int") 
test_eq(typeof(0.0),"float") 
test_eq(typeof(all_constants()["all_constants"]),"mixed") 
 
// class 
test_true(programp(class c {})) 
test_true(functionp(clone(class c { int foo() { return 1; }})->foo)) 
test_true(clone(class c { int foo() { return 1; }})->foo()) 
test_true(clone(class c { int i=1; })->i) 
test_false(clone(class c { int foo() { return 1; }})->bar) 
test_eq(clone(clone(class c { program foo=class c { int i=20; }; })->foo)->i,20) 
 
// type checks 
test_compile_error([[} int foo() { return]]); 
test_compile_error([[} void foo() { return 1]]); 
 
// Not yet cataloged 
test_any(int i=10; { int i; } return i, 10) 
test_program(void foo(int a ,int b); function(int,int:void) a() { return foo; }) 
test_program(void foo(int a, int ... b); function(int,int ...:void) a() { return foo; }) 
test_program(void foo(); function(:void) a() { return foo; }) 
test_compile_error([[} void foo(); function(:string) a() { return foo;]]) 
 
test_do(lambda(){return;}()) 
test_equal( ({ lambda() { return 3; } , lambda() { return 7; }, lambda() { return 9; } })(), ({ 3,7,9 })) 
test_any(int *a=({10}); a[0]++; return a[0], 11) 
test_any(mapping a=([10:11]); a[10]++; return a[10], 12) 
test_equal(mkmapping( ({3,6,2}), ({"3","6","2"})), ([3:"3", 6:"6", 2:"2"])) 
test_equal(`+(([3:"3", 6:"6", 2:"2"])), ([3:"3", 6:"6", 2:"2"])) 
test_true(`+(([3:"3", 6:"6", 2:"2"])) != ([3:"3", 6:"6", 2:"2"])) 
 
test_true(predef::stringp("")) 
test_equal([["a,b,4,7,8s,asfd,a,d,f" / ","]],[["a,b,4,7,8s,asfd,a,d,f" / ","]]) 
test_any([[string *a="a,b"/","; a[0]="c"; return equal(a,({"c","b"}))]],1) 
test_true(0||1) 
test_true(1||0) 
test_true(!0||!0) 
test_true(!0&&!0) 
test_any(mixed a=1; a+=1; return a,2) 
test_any(mixed a=1; a-=1; return a,0) 
test_equal("abcd"/"" - indices("abcd"),({"a","b","c","d"})) 
test_equal("abcd"/"" & indices("abcd"),({})) 
test_eq(sizeof("abcd"/"" & "de"/""),1) 
test_equal( ({0,0,0,0,0}), ({0,0,0,0,0})) 
test_equal( ({"object","object","object","object","object"}), allocate(5,"object")) 
test_equal(mkmapping("abcd"/"","jklm"/"") | mkmapping("jclm"/"","alcd"/""), 
        mkmapping("abcdjlm"/"","jklmacd"/"")) 
test_program(int foo() { return 17;} mixed a() { return foo() == 17; }) 
test_any([[mixed a; a=2; a=a*3; return a]],6) 
test_any([[mixed a = ({1}); a=a+({2}); return equal(a,({1,2}))]],1) 
test_define_program(test,[[int foo() { return 17; }]]) 
test_any(function bar=clone(test)->foo; return bar(),17) 
 
// sscanf 
test_any([[mixed a; return sscanf("11","%d",a)]],1) 
 
test_any([[mixed a; sscanf("11","%d",a); return a]],11) 
test_any([[mixed a; sscanf("11","%o",a); return a]],011) 
test_any([[mixed a; sscanf("11","%x",a); return a]],0x11) 
test_any([[mixed a; sscanf("11","%D",a); return a]],11) 
 
 
test_any([[mixed a; sscanf("11","%2d",a); return a]],11) 
test_any([[mixed a; sscanf("11","%2o",a); return a]],011) 
test_any([[mixed a; sscanf("11","%2x",a); return a]],0x11) 
test_any([[mixed a; sscanf("11","%2D",a); return a]],11) 
 
test_any([[mixed a; sscanf("11","%4711d",a); return a]],11) 
test_any([[mixed a; sscanf("11","%4711o",a); return a]],011) 
test_any([[mixed a; sscanf("11","%4711x",a); return a]],0x11) 
test_any([[mixed a; sscanf("11","%4711D",a); return a]],11) 
 
test_any([[mixed a; sscanf("11","%1d",a); return a]],1) 
test_any([[mixed a; sscanf("11","%1o",a); return a]],1) 
test_any([[mixed a; sscanf("11","%1x",a); return a]],1) 
test_any([[mixed a; sscanf("11","%1D",a); return a]],1) 
 
test_any([[mixed a; sscanf("0x11","%D",a); return a]],0x11) 
test_any([[mixed a; sscanf("011","%D",a); return a]],011) 
test_any([[mixed a,b; return sscanf("11foo","%dfoo",a)]],1) 
test_any([[mixed a,b; sscanf("11foo","%dfoo",a); return a]],11) 
test_any([[mixed a,b; return sscanf("11foo","%d%s",a,b)]],2) 
test_any([[mixed a,b; sscanf("11foo","%d%s",a,b); return b]],"foo") 
test_any([[mixed a,b; return sscanf("foo","%c%s",b,a)]],2) 
test_any([[mixed a,b; sscanf("foo","%c%s",b,a); return b]],'f') 
test_any([[mixed a,b; sscanf("foo","%c%s",b,a); return a]],"oo") 
test_any([[mixed a,b; return sscanf("1.0","%f",a)]],1) 
test_any([[mixed a,b; sscanf("1.0","%f",a); return a]],1.0) 
test_any([[mixed a,b; sscanf("-z ","%[-z]%s",a,b); return a]],"-z") 
test_any([[mixed a,b; sscanf("-z ","%[z-]%s",a,b); return a]],"-z") 
test_any([[mixed a,b; sscanf("abcdeFGji","%[a-z]%s",a,b); return a]],"abcde") 
test_any([[mixed a,b; sscanf("abcdeFGji","%[a-z]%s",a,b); return b]],"FGji") 
 
test_any([[mixed a,b; return sscanf("foo-%-bar","%s-%%-%s",a,b);]],2) 
test_any([[mixed a,b; sscanf("foo-%-bar","%s-%%-%s",a,b); return a]],"foo") 
test_any([[mixed a,b; sscanf("foo-%-bar","%s-%%-%s",a,b); return b]],"bar") 
test_any([[mixed a; sscanf("ab","%2c",a); return a]],'a'*256+'b') 
test_any([[mixed a; sscanf("abc","%3c",a); return a]],'a'*256*256+'b'*256+'c') 
test_any([[mixed a; sscanf("abc","%2c",a); return a]],'a'*256+'b') 
test_any([[mixed a; sscanf("ac","%3c",a); return a]],0) 
test_any([[mixed a; sscanf("ab","%2s",a); return a]],"ab") 
test_any([[mixed a; sscanf("abc","%3s",a); return a]],"abc") 
test_any([[mixed a; sscanf("abc","%2s",a); return a]],"ab") 
test_any([[mixed a; sscanf("ac","%3s",a); return a]],0) 
test_any([[mixed a; sscanf("a3","%*s%d",a); return a]],3) 
test_any([[mixed a; sscanf("a3","%s%*d",a); return a]],"a") 
test_any([[mixed a; sscanf("a93","%s%*o",a); return a]],"a9") 
test_any([[mixed a; sscanf("a93","%*s%o",a); return a]],3) 
test_any([[mixed a; sscanf("a93","%s%*x",a); return a]],"") 
test_any([[mixed a; sscanf("a93","%*s%x",a); return a]],0xa93) 
test_any([[mixed a; sscanf("f","f%n",a); return a]],1) 
 
test_any([[mixed a; sscanf("\102\052\100\000","%F",a); return a]],42.5625) 
test_any([[mixed a; sscanf("\102\052\100\000","%4F",a); return a]],42.5625) 
test_any([[mixed a; sscanf("\100\105\110\000\0\0\0\0","%8F",a); return a]],42.5625) 
test_any([[mixed a; sscanf("\275\007\053\002","%4F",a); return a]],-0.032999999821186065673828125) 
test_any([[mixed a; sscanf("\277\240\345\140\100\0\0\0","%8F",a); return a]],-0.032999999821186065673828125) 
 
test_equal([[array_sscanf("10 20 30","%d %d %d")]],[[({10,20,30})]]) 
test_equal([[array_sscanf("1 2 3 4 5 6 7 8 9","%d %d %d %d %d %d %d %d %s")]],[[({1,2,3,4,5,6,7,8,"9"})]]) 
test_equal([[array_sscanf("abc","%{%c%}")]],[[ ({ ({ ({'a'}), ({'b'}), ({'c'}) }) }) ]]) 
 
// Basics 
test_true(1) 
test_true("") 
test_true(!0) 
test_true(!(!1)) 
test_true(this_object()) 
test_true(a) // a is the test function 
test_true(0.0) 
test_true(([])) 
test_true(({})) 
test_true((<>)) 
test_true(object_program(this_object())) 
 
// testing ! 
test_equal(!"",0) 
test_equal(!this_object(),0) 
test_equal(!Simulate.this_function(),0) 
 
// testing == 
test_true(1==1) 
test_true(!(1==2)) 
test_true(""=="") 
test_true(!(""=="foo")) 
test_true(this_object()==this_object()) 
test_true(Simulate.this_function()==a) 
test_true(2.0==2.0) 
test_true(({})==({})) 
 
// testing != 
test_true(({1})!=({1})) 
test_true(1!=2) 
test_true(!(1==2)) 
test_true(!(""!="")) 
test_true(""!="foo") 
 
test_cmp3(1,2,3) 
test_cmp3(1.0,2.0,3.0) 
test_cmp3(1,2.0,3.6) 
test_cmp3(1.0,2,4) 
test_cmp3("a","b","c") 
test_cmp3("","b","cc") 
 
// hex construction 
test_eq(0,0x0) 
test_eq(1,0x1) 
test_eq(10,0xa) 
test_eq(16,0x10) 
test_eq(65535,0xffff) 
test_eq(17*257*65537,0x11111111) 
 
// octal construction 
test_eq(0,00) 
test_eq(1,01) 
test_eq(8,010) 
test_eq(64,0100) 
test_eq(1073741824,010000000000) 
test_eq((8+1)*(8*8+1)*(8*8*8*8+1),011111111) 
 
// string construction tests 
test_eq(16,"\20"[0]) 
test_eq(16,"\020"[0]) 
test_eq(255,"\377"[0]) 
test_eq(4,'\4') 
test_true("\r"[0]!='r') 
test_eq("\r"[0],'\r') 
test_eq("\n"[0],'\n') 
 
// testing + 
test_eq(1+1,2) 
test_eq(1+(-2),-1) 
test_eq((-2)+(-2),-4) 
test_eq("hi"+"there","hithere") 
test_eq("human"+"number"+666,"humannumber666") 
test_eq("human"+("number"+666),"humannumber666") 
test_eq(("human"+"number")+666,"humannumber666") 
test_eq(("human"+"number")+666+111,"humannumber666111") 
test_eq("humannumber"+(666+111),"humannumber777") 
test_eq("a"+"b"+"c"+"d"+"e"+"f"+"g"+"h"+"i"+"j"+"k"+"l"+"m"+"n"+"o"+"p"+"q"+"r"+"s"+"t"+"u"+"v"+"x"+"y","abcdefghijklmnopqrstuvxy") 
test_eq(1.0+1.0,2.0) 
test_eq(1.0+(-1.0),0.0) 
test_eq((-1.0)+(-1.0),-2.0) 
test_eq(1.0+1,2.0) 
test_eq(1+1.0,2.0) 
test_eq(1+(-1.0),0.0) 
test_eq(1.0+(-1),0.0) 
test_eq((-1)+(-1.0),-2.0) 
test_eq((-1.0)+(-1),-2.0) 
test_equal(({1,2,3})+({4,5,6}),({1,2,3,4,5,6})) 
test_equal((<1,2,3,4>)+(<4,5,6>),(<1,2,3,4,4,5,6>)) 
test_equal(([0:1,3:6])+([5:2,3:6]),([0:1,3:6,3:6,5:2])) 
test_eval_error(return this_object() + this_object()) 
 
// testing - 
test_eq(10-3,7) 
test_eq(3-10,-7) 
test_eq(10.0-3.0,7.0) 
test_eq(3.0-10.0,-7.0) 
test_eq(10-3.0,7.0) 
test_eq(3-10.0,-7.0) 
test_eq(10.0-3,7.0) 
test_eq(3.0-10,-7.0) 
test_eq("foobargazonk"-"o","fbargaznk") 
test_equal(({"foo","bar","gazonk"})-({"foo","gazonk"}),({"bar"})) 
test_equal(({"c","foo","bar","gazonk","a","b",})-({"foo","gazonk"}),({"c","bar","a","b"})) 
test_equal((<"foo","bar","gazonk">)-(<"foo","gazonk">),(<"bar">)) 
test_equal((["foo":3,"bar":4,"gazonk":5])-(["foo":3,"gazonk":8]),(["bar":4])) 
 
// testing ~ 
test_eq(-1-4,~4) 
test_eq(-1-627893874,~627893874) 
test_eq(~1.0,-2.0) 
test_eq(~"\x55","\xaa") 
 
// testing * 
test_eq(3*4,12) 
test_eq(4*3,12) 
test_eq(2*2*2*2*2,32) 
test_eq(3.0*4.0,12.0) 
test_eq(4.0*3.0,12.0) 
test_eq(2.0*2.0*2.0*2.0*2.0,32.0) 
test_eq(3*4.0,12.0) 
test_eq(4*3.0,12.0) 
test_eq(2*2.0*2.0*2.0*2.0,32.0) 
test_eq(3.0*4,12.0) 
test_eq(4.0*3,12.0) 
test_eq(2.0*2*2.0*2*2.0,32.0) 
test_eq(({"foo","bar","gazonk"})*"-","foo-bar-gazonk") 
test_equal( ({ ({1}), ({2}), ({3}) })*({8}), ({1,8,2,8,3})) 
test_equal( ({ 1 })*3, ({1,1,1}) ) 
test_equal( "foo"*3, "foofoofoo" ) 
 
// testing / 
test_eq(12/3,4) 
test_eq(13/3,4) 
test_eq(14/3,4) 
test_eq(15/3,5) 
test_eq(-2/4,-1) 
test_eq(-12/3,-4) 
test_eq(-13/3,-5) 
test_eq(-14/3,-5) 
test_eq(-15/3,-5) 
test_eval_error(return 15/0) 
test_eq(12.0/3.0,4.0) 
test_eq(14.0/4.0,3.5) 
test_eq(15.0/3.0,5.0) 
test_eq(12/3.0,4.0) 
test_eq(14/4.0,3.5) 
test_eq(15/3.0,5.0) 
test_eq(12.0/3,4.0) 
test_eq(14.0/4,3.5) 
test_eq(15.0/3,5.0) 
test_eval_error(return 15.0/0.0) 
test_equal("foo-bar-gazonk"/"-",({"foo","bar","gazonk"})) 
test_equal("foobargazonk"/"",({"f","o","o","b","a","r","g","a","z","o","n","k"})) 
test_equal(({1,0,1,2,1,2,2,2,1,1,1})/({2}),({ ({1,0,1}), ({1}), ({}), ({}), ({1,1,1}) })) 
test_equal(({1,2,3,4})/({}),({ ({1}), ({2}), ({3}), ({4}) })) 
test_equal(({1,0,1,2,1,2,2,2,1,1,1})/({2,1}),({ ({1,0,1}), ({2,2}), ({1,1}) })) 
test_equal( ({1,2,3})/({2,3}), ({ ({1}), ({}) }) ) 
test_eq([[`/(20,2,2)]],5) 
test_eq([[`/(13,2,3)]],2) 
test_equal("foobargazonk"/1,"foobargazonk"/"") 
test_equal("foobargazonk"/2,({"fo","ob","ar","ga","zo","nk"})) 
test_equal("foobargazonk"/3,({"foo","bar","gaz","onk"})) 
test_equal("foobargazonk"/4,({"foob","arga","zonk"})) 
test_equal("foobargazonk"/5,({"fooba","rgazo"})) 
test_equal("foobargazonk"/-6,({"foobar","gazonk"})) 
test_equal("foobargazonk"/-7,({"rgazonk"})) 
 
test_equal("foobargazonk"/5.0,({"fooba","rgazo","nk"})) 
test_equal("foobargazonk"/-5.0,({"fo","obarg","azonk"})) 
test_equal("foobargazonk"/2.5,({"fo","oba","rg","azo","nk"})) 
 
test_equal(({1,2,3})/1,({ ({1}), ({2}), ({3}) })) 
test_equal(({1,2,3})/2,({ ({1,2}) })) 
test_equal(({1,2,3})/-2,({ ({2,3}) })) 
 
test_equal(({1,2,3})/2.0,({ ({1,2}), ({3}) })) 
test_equal(({1,2,3})/-2.0,({ ({1}), ({2,3}) })) 
test_equal(({1,2,3})/1.5,({ ({1}), ({2,3}) })) 
 
// testing % 
test_eq(12%3,0) 
test_eq(13%3,1) 
test_eq(14%3,2) 
test_eq(15%3,0) 
test_eq(2%17,2) 
test_eq(2%-17,-15) 
test_eq(-2%17,15) 
test_eq(-2%-17,-2) 
test_eq(-10%10,0) 
test_eq(10%-10,0) 
test_eq(-10%-10,0) 
test_eq(10%10,0) 
test_eval_error(return 15 % 0) 
test_eq(12.0 % 3.0,0.0) 
test_eq(13.0 % 3.0,1.0) 
test_eq(14.0 % 3.0,2.0) 
test_eq(14.5 % 3.0,2.5) 
test_eq(15.0 % 3.0,0.0) 
test_eq(13 % 3.0,1.0) 
test_eq(14 % 3.0,2.0) 
test_eq(13.0 % 3,1.0) 
test_eq(14.0 % 3,2.0) 
test_eq(14.5 % 3,2.5) 
test_eval_error(return 15.0 % 0.0) 
 
test_eq("foobargazonk"%5,"nk") 
test_eq("foobargazonk"%-5,"fo") 
test_equal(({1,2,3})%2,({3})) 
test_equal(({1,2,3})%-2,({1})) 
 
 
// testing && 
test_eq(0 && 1,0) 
test_eq(1 && 0,0) 
test_eq(0 && 0,0) 
test_eq(1 && 1,1) 
test_eq(78 && 1,1) 
test_eq(78 && 99,99) 
test_eq(78 && 99,99) 
 
// testing || 
test_eq(0 || 1,1) 
test_eq(1 || 0,1) 
test_eq(0 || 0,0) 
test_eq(1 || 1,1) 
test_eq(78 || 1,78) 
test_eq(78 || 0,78) 
 
// testing | 
test_eq(0 | 0,0) 
test_eq(1 | 1,1) 
test_eq(4 | 1,5) 
test_eq(1 | 9,9) 
test_equal( Array.sort_array(({1,2,3,4,4}) | ({3,5,6})), ({1,2,3,4,4,5,6})) 
test_equal( (<4,5,6>) | (<5,5,5>), (<4,5,5,5,6>) ) 
test_equal( ([-4:8,8:7]) | ([3:3,8:3]), ([-4:8,8:3,3:3]) ) 
 
// testing & 
test_eq(0 & 0,0) 
test_eq(1 & 1,1) 
test_eq(4 & 1,0) 
test_eq(1 & 9,1) 
test_equal( ({1,2,3,4,4}) & ({3,5,6}), ({3})) 
test_equal( (<4,5,6>) & (<5,5,5>), (<5>) ) 
test_equal( ([-4:8,8:7]) & ([3:3,8:3]), ([8:3]) ) 
 
// testing ^ 
test_eq(0 ^ 0,0) 
test_eq(1 ^ 1,0) 
test_eq(4 ^ 1,5) 
test_eq(1 ^ 9,8) 
test_equal( ({1,2,3,4,4}) ^ ({3,5,6}), ({1,2,4,4,5,6})) 
test_equal( (<4,5,6>) ^ (<5,5,5>), (<4,5,5,6>) ) 
test_equal( ([-4:8,8:7]) ^ ([3:3,8:3]), ([-4:8,3:3]) ) 
 
// testing << 
test_eq(1<<0,1) 
test_eq(1<<1,2) 
test_eq(1<<10,1024) 
test_eq(5<<3,40) 
 
// testing >> 
test_eq(9>>2,2) 
test_eq(1>>1,0) 
test_eq(1024>>10,1) 
test_eq(47>>3,5) 
 
// testing ? : 
test_true(0?0:1) 
test_true(1?1:0) 
test_true(""?1:0) 
test_true(!0?1:0) 
test_true(!(!1)?1:0) 
test_true(this_object()?1:0) 
test_true(a?1:0) // a is the test function 
test_true(0.0?1:0) 
test_true(([])?1:0) 
test_true(({})?1:0) 
test_true((<>)?1:0) 
test_true(object_program(this_object())?1:0) 
 
// testing indexing 
test_eq("foo"[0],'f') 
test_eq("foo"[1],'o') 
test_eq("foo"[2],'o') 
test_eq("foo"[-1],'o') 
test_eq("foo"[-2],'o') 
test_eq("foo"[-3],'f') 
test_eq(({'f','o','o'})[0],'f') 
test_eq(({'f','o','o'})[1],'o') 
test_eq(({'f','o','o'})[2],'o') 
test_eq(({'f','o','o'})[-1],'o') 
test_eq(({'f','o','o'})[-2],'o') 
test_eq(({'f','o','o'})[-3],'f') 
test_eq(([0:'f',1:'o',2:'o'])[0],'f') 
test_eq(([0:'f',1:'o',2:'o'])[1],'o') 
test_eq(([0:'f',1:'o',2:'o'])[2],'o') 
test_eq(([0:'f',1:'o',2:'o'])[3],0) 
test_eq(([0:'f',1:'o',2:'o'])[-1],0) 
test_eq((<'f','o','o'>)['o'],1) 
test_eq((<'f','o','o'>)['f'],1) 
test_eq((<'f','o','o'>)['b'],0) 
test_eq((<'f','o','o'>)[-1],0) 
 
test_eq([[class Z { mixed `->(mixed x) { return this_object()[x]; } int foo() { return 1; }}()->foo()]],1) 
 
// index assigning 
test_any(mixed a=({1}); a[0]=2; return equal(a,({2})),1) 
test_any(mixed a=(<1>); a[1]=2; return equal(a,(<1>)),1) 
test_any(mixed a=(<1>); a[0]=2; return equal(a,(<1,0>)),1) 
test_any(mixed a=(<1>); a[1]=0; return equal(a,(<>)),1) 
test_any(mixed a=(<1>); a[0]=0; return equal(a,(<1>)),1) 
test_any(mixed a=([1:1]); a[0]=0; return equal(a,([1:1,0:0])),1) 
test_any(mixed a=([1:1]); a[1]=0; return equal(a,([1:0])),1) 
 
test_define_program(test,[[public int q,w,e,r; mixed t; mixed getw() { return w; } void setw(int _) { w=_; }]]) 
test_eq(clone(test)->q,0) 
test_eq(clone(test)->w,0) 
test_eq(clone(test)->e,0) 
test_eq(clone(test)->r,0) 
test_eq(clone(test)->getw(),0) 
test_any(object o=clone(test); o->setw(17); return o->w,17) 
test_any(object o=clone(test); o->w=17; return o->getw(),17) 
 
test_eq(clone(test)["q"],0) 
test_eq(clone(test)["w"],0) 
test_eq(clone(test)["e"],0) 
test_eq(clone(test)["r"],0) 
test_eq(clone(test)["getw"](),0) 
test_any(object o=clone(test); o["setw"](17); return o["w"],17) 
test_any(object o=clone(test); o["w"]=17; return o["getw"](),17) 
 
// testing range 
test_eq("foObar"[0..0],"f") 
test_eq("foobargazonk"[3..5],"bar") 
test_eq("foo"[1..10],"oo") 
test_eq("foo"[-100..0],"f") 
test_eq("foo"[-100..100],"foo") 
test_eq("foo"[1..0],"") 
test_eq("foo"[0..-100],"") 
test_eq("foobargazonk"[0..],"foobargazonk") 
test_eq("foobargazonk"[1..],"oobargazonk") 
test_eq("foobargazonk"[5..],"rgazonk") 
test_eq("foobargazonk"[..2],"foo") 
test_eq("foobargazonk"[..5],"foobar") 
test_equal(({1,2,3})[0..0],({1})) 
test_equal(({1,2,3})[1..2],({2,3})) 
test_equal(({1,2,3})[2..10],({3})) 
test_equal(({1,2,3})[-100..0],({1})) 
test_equal(({1,2,3})[-100..100],({1,2,3})) 
test_equal(({1,2,3})[1..0],({})) 
test_equal(({1,2,3})[0..-100],({})) 
 
// casting 
test_eq([[(int)1]],[[1]]) 
test_eq([[(int)1.0]],[[1]]) 
test_eq([[(int)"1"]],[[1]]) 
test_eq([[(float)"1"]],[[1.0]]) 
test_eq([[(float)"1.0"]],[[1.0]]) 
test_eq([[(float)1.0]],[[1.0]]) 
test_eq([[(float)1]],[[1.0]]) 
test_eq([[(string)1]],[["1"]]) 
test_equal([[(array)(["1":1])]],[[ ({ ({"1", 1}) }) ]]) 
test_equal([[(array(int)) ({"1","4711",2.0,4})]],[[({1,4711,2,4})]]) 
test_equal([[(array(array))({({})})]],[[({({})})]]) 
test_equal([[ (array(array(int))) ({ ({"1","4711",2.0,4}) }) ]],[[ ({ ({1,4711,2,4}) }) ]]) 
test_equal([[ (array(array(array(int)))) ({ ({ ({"1","4711",2.0,4}) }) }) ]],[[ ({ ({ ({1,4711,2,4}) }) }) ]]) 
test_equal([[ (array(array(array(array(int))))) ({ ({ ({ ({"1","4711",2.0,4}) }) }) }) ]],[[ ({ ({ ({ ({1,4711,2,4}) }) }) }) ]]) 
 
test_equal([[(array)"foo"]],[[ values("foo") ]]) 
test_equal([[(array)(<1,2,3>)]],[[ indices( (<1,2,3>) )]]) 
test_equal([[sort(column((array)([1:2,3:4]),0))]],[[ sort(indices(([1:2,3:4])) )]]) 
test_equal([[sort(column((array)([1:2,3:4]),1))]],[[ sort(values(([1:2,3:4])))]]) 
test_true([[(array(array))([]) ]]) 
test_true([[(array(array))([1:2]) ]]) 
test_true([[(array(array))([1:2,3:4]) ]]) 
test_true([[(array(array))([1:2,3:4,5:6]) ]]) 
 
// testing @ 
test_equal(({1,2,3}),lambda(mixed ... x) { return x; }(@a())) 
test_equal("foo"/"",lambda(mixed ... x) { return x; }(@a())) 
test_any([[mixed *a=({1,2,3}); return lambda(mixed ... x) { return x; }(@a) !=a]],1) 
 
// testing += 
test_any(int a=1; a+=10; return a,11) 
// testing -= 
test_any(int a=1; a-=10; return a,-9) 
// testing &= 
test_any(int a=3; a&=10; return a,2) 
// testing |= 
test_any(int a=3; a|=10; return a,11) 
// testing ^= 
test_any(int a=3; a^=10; return a,9) 
// testing <<= 
test_any(int a=3; a<<=2; return a,12) 
// testing <<= 
test_any(int a=12; a>>=2; return a,3) 
// testing *= 
test_any(int a=12; a*=2; return a,24) 
// testing /= 
test_any(int a=12; a/=2; return a,6) 
// testing %= 
test_any(int a=12; a%=7; return a,5) 
 
// testing control structs 
test_any(return 1,1) 
test_any(return lambda(){return 1;} (),1 ) 
test_any(if(0) return 0; else return 1,1) 
test_any(if(0) return 0; return 1,1) 
test_any(if(1) return 1; else return 0,1) 
test_any(if("") return 1; else return 0,1) 
test_any(if(!0) return 1; else return 0,1) 
test_any(if(!(!1)) return 1; else return 0,1) 
test_any(if(this_object()) return 1; else return 0,1) 
test_any(if(a) return 1; else return 0,1) dnl a is the test function 
test_any(if(0.0) return 1; else return 0,1) 
test_any(if(([])) return 1; else return 0,1) 
test_any(if(({})) return 1; else return 0,1) 
test_any(if((<>)) return 1; else return 0,1) 
test_any(if(object_program(this_object())) return 1; else return 0,1) 
 
// break 
test_any(while(1) break; return 1,1) 
test_any(while(1) if(1) break; return 1,1) 
 
// for 
test_program( 
int* ia=({1,2,3,4,5,6}); 
 
int a() 
{ 
  int i; 
  for (i=0; i<sizeof(ia); i++) 
    { 
      if (ia[i]==3) 
        { 
          ia=ia[..i-1]+ia[i+1..]; 
          --i; 
        } 
    } 
  return 1; 
} 
) 
test_any(int e; for(e=0;e<10;e++) break; return e,0) 
test_any(int e; for(e=0;e<10;e++) continue; return e,10) 
test_any(int e;string t=""; for(e=0;e<10;e++) t+=e; return t,"0123456789") 
test_any(int e;string t=""; for(e=0;e<=10;e++) t+=e; return t,"012345678910") 
test_any(int e;string t=""; for(e=9;e>0;e--) t+=e; return t,"987654321") 
test_any(int e;string t=""; for(e=9;e>=0;e--) t+=e; return t,"9876543210") 
test_any(int e;string t=""; for(e=9;e!=0;e--) t+=e;  return t,"987654321") 
test_any(int e;string t=""; for(e=2;e!=10;e++) t+=e; return t,"23456789") 
test_any(int e;string t=""; for(e=0;e>-10;e--) t+=e; return t,"0-1-2-3-4-5-6-7-8-9") 
 
// foreach 
test_any([[int e;string t=""; foreach(({7,6,3,8}),e) t+=e; return t]],"7638") 
test_any([[string s;if(1) foreach(({}),s); else foreach(({}),s); return 1]],1) 
 
// do-while 
test_any(int e;string t=""; e=0; do{ t+=e; }while(++e<6); return t,"012345";) 
 
// while 
test_any(int e;string t=""; e=8; while(--e) t+=e; return t,"7654321";) 
test_any(int e;string t=""; e=8; while(e--) t+=e; return t,"76543210";) 
test_any(int e;string t=""; e=0; while(++e<6) t+=e; return t,"12345";) 
test_any(int e=1;string t=""; while(e<20){t+=e;e*=2;} return t,"124816";) 
 
// Switch 
test_any(switch("") { case -1: case "gazonk": return 0; } return 1,1) 
test_any(switch("") { case -2: case "gazonk": return 0; } return 1,1) 
test_any(switch("") { case 0: case "gazonk": return 0; } return 1,1) 
test_any(switch("") { case "gazonk": case 0: return 0; } return 1,1) 
test_any(switch(0) { case 0: case "gazonk": return 0; } return 1,0) 
test_any(switch("gazonk") { case "gazonk": case 0: return 0; } return 1,0) 
test_any(switch(0) { case "": } return 1,1) 
test_any(switch(1) { case 1: return 1; default: } return 0,1) 
test_any(switch(2) { case 1: return 0; default: return 1;} return 0,1) 
test_any(switch(1) { default: return 0; case 1: return 1; } return 0,1) 
test_any(switch(2) { default: return 1; case 1: return 0; } return 0,1) 
test_any(switch(0) { case "apa": case 1.0: return 0; }  return 1,1) 
test_any(switch("apa") { case "apa": return 1; case 1.0: }  return 0,1) 
test_any(switch(1.0) { case "apa": return 0; case 1.0: return 1; } return 0,1) 
test_any(switch("sune") { case "gunnel": return 0; case "gunnar": return 1; case "sune": case "gusten": return 0; } return 0,0) 
test_any(switch("a") { case "a": return 1; case "b": case "c": case "d": case 'a': case '1': case '0': default: } return 0,1) 
test_any(switch("b") { case "a": return 0; case "b": return 1; case "c": case "d": case 'a': case '1': case '0': default: } return 0,1) 
test_any(switch("c") { case "a": case "b": return 0; case "c": return 1; case "d": case 'a': case '1': case '0': default: } return 0,1) 
test_any(switch("d") { case "a": case "b": case "c": return 0; case "d": return 1; case 'a': case '1': case '0': default: } return 0,1) 
test_any(switch('a') { case "a": case "b": case "c": case "d": return 0; case 'a': return 1; case '1': case '0': default: } return 0,1) 
test_any(switch('1') { case "a": case "b": case "c": case "d": case 'a': return 0; case '1': return 1; case '0': default: } return 0,1) 
test_any(switch('0') { case "a": case "b": case "c": case "d": case 'a': case '1': return 0; case '0': return 1; default: } return 0,1) 
test_any(switch("a") { case "a": return 1; case "b": return 2; case "c": return 3; case "d": return 4; case 'a': return 5; case '1': return 6; case '0': return 7; default: return 8; } return 9,1) 
test_any(switch("b") { case "a": return 1; case "b": return 2; case "c": return 3; case "d": return 4; case 'a': return 5; case '1': return 6; case '0': return 7; default: return 8; } return 9,2) 
test_any(switch("c") { case "a": return 1; case "b": return 2; case "c": return 3; case "d": return 4; case 'a': return 5; case '1': return 6; case '0': return 7; default: return 8; } return 9,3) 
test_any(switch("d") { case "a": return 1; case "b": return 2; case "c": return 3; case "d": return 4; case 'a': return 5; case '1': return 6; case '0': return 7; default: return 8; } return 9,4) 
test_any(switch('a') { case "a": return 1; case "b": return 2; case "c": return 3; case "d": return 4; case 'a': return 5; case '1': return 6; case '0': return 7; default: return 8; } return 9,5) 
test_any(switch('1') { case "a": return 1; case "b": return 2; case "c": return 3; case "d": return 4; case 'a': return 5; case '1': return 6; case '0': return 7; default: return 8; } return 9,6) 
test_any(switch('0') { case "a": return 1; case "b": return 2; case "c": return 3; case "d": return 4; case 'a': return 5; case '1': return 6; case '0': return 7; default: return 8; } return 9,7) 
test_any(switch('9') { case "a": return 1; case "b": return 2; case "c": return 3; case "d": return 4; case 'a': return 5; case '1': return 6; case '0': return 7; default: return 8; } return 9,8) 
 
 
define(test_switch0,[[ 
test_any(switch($1) { $2; $3; $4; $5; } return 0,$6) 
test_any(switch($1) { default: return 0; $2; $3; $4; $5; } return -1,$6) 
test_any(switch($1) { $2; default: return 0; $3; $4; $5; } return -1,$6) 
test_any(switch($1) { $2; $3; default: return 0; $4; $5; } return -1,$6) 
test_any(switch($1) { $2; $3; $4; default: return 0; $5; } return -1,$6) 
test_any(switch($1) { $2; $3; $4; $5; default: return 0; } return -1,$6) 
]]) 
 
define(test_switch1,[[ 
test_switch0($1, $2,$3,$4,$5, $6) 
test_switch0($1, $2,$3,$5,$4, $6) 
]]) 
 
define(test_switch2,[[ 
test_switch1($1, $2,$3,$4,$5, $6) 
test_switch1($1, $2,$4,$3,$5, $6) 
test_switch1($1, $2,$5,$4,$3, $6) 
]]) 
 
define(test_switch3,[[ 
test_switch2($1,case $2:return 2,case $3:return 3,case $4:return 4,case $5:return 5,$6) 
test_switch2($1,case $3:return 3,case $2:return 2,case $4:return 4,case $5:return 5,$6) 
test_switch2($1,case $4:return 4,case $3:return 3,case $2:return 2,case $5:return 5,$6) 
test_switch2($1,case $5:return 5,case $3:return 3,case $4:return 4,case $2:return 2,$6) 
]]) 
 
define(test_switch4,[[ 
test_switch3($1,$2,$3,$4,$5,0) 
test_switch3($2,$2,$3,$4,$5,2) 
test_switch3($3,$2,$3,$4,$5,3) 
test_switch3($4,$2,$3,$4,$5,4) 
test_switch3($5,$2,$3,$4,$5,5) 
]]) 
 
test_switch4(17,18,19,20,21) 
test_switch4("a","b","c","d","e") 
test_switch4("a",0,"c","d","e") 
test_switch4(1.0,2.0,3.0,4.0,5.0) 
test_switch4(this_object(),"",0,4.0,1) 
 
test_any(int e;string t=""; for(e=0;e<10;e++) switch(e) { default: t+=e; case 4..8: } return t,"01239") 
test_any([[float e,q; q=0.0; for(e=0.1;e<10.0;e+=1.0) switch(e) { default: q+=e; case 4.0..8.0: } return q]],0.1+1.1+2.1+3.1+8.1+9.1) 
 
cond([[all_constants()->_verify_internals]], 
[[ 
  test_do(_verify_internals()) 
]]) 
 
// testing preprocessor 
test_any(int e; object o=clone(Stdio.File); if(!o->open("conftest.h","wct")) return -1; e=o->write("return 17;\n"); if(!o->close()) return -1; return e,11) 
test_any([[ 
#include "conftest.h" 
]],17) 
dnltest_any([[ 
dnl#include <conftest.h> 
dnl]],17) 
test_true(intp(__LINE__)) 
test_true(stringp(__FILE__)) 
test_true(stringp(__DATE__)) 
test_true(stringp(__TIME__)) 
 
// #define 
test_any([[ 
#define FOOa 1 
return FOOa; 
]],1) 
 
test_any([[ 
#define FOOa array 
FOOa(int) b; 
return 1; 
]],1) 
 
test_any([[ 
#define FOOb 17 
#undef FOOb 
#define FOOb 1 
return FOOb; 
]],1) 
 
test_compile_error([[ 
#define FOOc FOOc FOO 
FOO 
]]) 
 
test_compile_error([[ 
#error FOOd 
FOO 
]]) 
 
// /* */ 
test_any([[ 
/* return 99; * /  /* */ 
return 1; 
]],1) 
 
// // 
test_any([[ 
// return 99; 
return 1; 
]],1) 
 
// #if 
define(test_if_true,[[test_any([[ 
#if $1 
return 1; 
#else 
return 0; 
#endif 
]],1)]]) 
define(test_if_false,[[test_any([[ 
#if $1 
return 1; 
#else 
return 0; 
#endif 
]],0)]]) 
 
test_if_true(1) 
test_if_false(0) 
 
// #if == 
test_if_true(1==1) 
test_if_false(1==2) 
 
// #if != 
test_if_true(1!=2) 
test_if_false(1!=1) 
 
// #if ( ) 
test_if_true( (((1))==1) ) 
test_if_false( ((1)==(2)) ) 
 
// #if -1 
test_if_true( -1 ) 
test_if_true( (-1) ) 
test_if_true( (-1==0-1) ) 
 
// #if ~ 
test_if_true( (-1-1==~1) ) 
 
// #if ?: 
test_if_true( 17 == ( 1 ? 17 : 18 ) ) 
test_if_true( 18 == ( 0 ? 17 : 18 ) ) 
 
// #if || 
test_if_true( 10 == ( 10 || 20 ) ) 
test_if_true( 20 == ( 0 || 20 ) ) 
 
// #if && 
test_if_true( 0 == ( 0 && 20 ) ) 
test_if_true( 20 == ( 10 && 20 ) ) 
 
// #if | 
test_if_true( 3 == ( 1 | 2 ) ) 
test_if_true( 2 == ( 2 | 2 ) ) 
 
// #if ^ 
test_if_true( 0 == ( 2 ^ 2 ) ) 
test_if_true( 3 == ( 1 ^ 2 ) ) 
 
// #if & 
test_if_true( 0 == ( 1 & 2 ) ) 
test_if_true( 2 == ( 2 & 7 ) ) 
 
// #if <= >= < > ! strings, floats 
 
define(test_if_cmp,[[ 
test_if_true($1<$2) 
test_if_true(!($1>$2)) 
test_if_true($2>$1) 
test_if_true(!($2<$1)) 
test_if_true($1<=$2) 
test_if_true(!($1>=$2)) 
test_if_true($2>=$1) 
test_if_true(!($2<=$1)) 
test_if_true($2<=$2) 
test_if_true($1>=$1) ]]) 
 
test_if_cmp(1,2) 
test_if_cmp(1.0,2.0) 
test_if_cmp("a","b") 
 
// #if << 
test_if_true(1<<10==1024) 
test_if_true(5<<3==40) 
 
// #if >> 
test_if_true(1024>>10==1) 
test_if_true(47>>3==5) 
 
// #if + 
test_if_true(1024+10==1034) 
test_if_true(47+3==50) 
 
// #if - 
test_if_true(1024-10==1014) 
test_if_true(47-3==44) 
 
// #if * 
test_if_true(1024*10==10240) 
 
// #if / 
test_if_true(47/3==15) 
 
test_compile_error([[ 
#if 1/0 
return 1; 
#else 
return 0; 
#endif 
]]) 
 
// #if % 
test_if_true(47%3==2) 
test_compile_error([[ 
#if 1%0 
return 1; 
#else 
return 0; 
#endif 
]]) 
 
// #if [ ] 
test_if_true("foo"[0]=='f') 
 
// #if defined 
test_any([[ 
#define FOOe 0 
#if defined(FOOe) 
return 1; 
#else 
return 0; 
#endif 
]],1) 
 
// #if define < x 
test_any([[ 
#define FOOf 1 
#if FOOf < 2 
return 1; 
#else 
return 0; 
#endif 
]],1) 
 
// #if define < x 
test_any([[ 
#define FOOg 1 
#if FOOg < 0 
return 0; 
#else 
return 1; 
#endif 
]],1) 
 
// #if x < define 
test_any([[ 
#define FOOh 1 
#if 0 < FOOh 
return 1; 
#else 
return 0; 
#endif 
]],1) 
 
// #if x < define 
test_any([[ 
#define FOOi 1 
#if 2 < FOOi 
return 0; 
#else 
return 1; 
#endif 
]],1) 
 
// #if efun 
// see test for add_constant() 
 
// #if /* */ 
test_any([[ 
#if 1 /* trying to be mean //  * / */ /* /* */ 
return 1;  /* */ 
#define foo 
# 1 "---" 
#undef foo 
#else /* trying to be mean //  * / */ /* /* */ 
return 0;  // 
#endif /* trying to be mean //  * / */ /* /* */ 
]],1) 
 
test_any([[ 
#if 0 /* trying to be mean //  * / */ /* /* */ 
return 0; /* */ 
#define foo 
# 1 "---" 
#undef foo 
#else /* trying to be mean //  * / */ /* /* */ 
return 1; // 
#endif /* trying to be mean //  * / */ /* /* */ 
]],1) 
 
// #if // 
test_any([[ 
#if 1 //* trying to be mean //  */ */ 
return 1; 
#else //* trying to be mean //  */ */ 
return 0; 
#endif //* trying to be mean //  */ */ 
]],1) 
 
test_any([[ 
#if 0 //* trying to be mean //  */ */ 
return 0; 
#else //* trying to be mean //  */ */ 
return 1; 
#endif //* trying to be mean // */ */ 
]],1) 
 
test_any([[ 
#define FOOj 
#if defined(FOOj) 
return 1; 
#else 
return 0; 
#endif 
]],1) 
 
test_any([[ 
#if defined(FOOk) 
return 0; 
#else 
return 1; 
#endif 
]],1) 
 
// #ifdef 
test_any([[ 
#ifdef FOOl 
return 0; 
#else 
return 1; 
#endif 
]],1) 
 
test_any([[ 
#define FOOm 
#ifdef FOOm 
return 1; 
#else 
return 0; 
#endif 
]],1) 
 
// #ifndef 
test_any([[ 
#define FOOo 
#ifndef FOOo 
return 0; 
#else 
return 1; 
#endif 
]],1) 
 
test_any([[ 
#ifndef FOOp 
return 1; 
#else 
return 0; 
#endif 
]],1) 
 
// #else 
test_any([[ 
#if 1 
return 1; 
#else 
FEL 
#if 0 
FEL 
#else 
FEL 
#endif 
return 0; 
#endif 
]],1) 
 
test_any([[ 
#if 0 
FEL 
#if 0 
FEL 
#else 
FEL 
#if 1 
FEL 
#else 
FEL 
#endif 
#endif 
return 0; 
#else 
return 1; 
#endif 
]],1) 
 
// #elif 
test_any([[ 
#if 0 
return 0; 
#elif 0 
return 0; 
#else 
return 1; 
#endif 
]],1) 
 
test_any([[ 
#if 0 
return 0; 
#elif 1 
return 1; 
#else 
return 0; 
#endif 
]],1) 
 
test_any([[ 
#if 1 
return 1; 
#elif 1 
return 0; 
#else 
return 0; 
#endif 
]],1) 
 
// #elseif 
test_any([[ 
#if 0 
return 0; 
#elseif 0 
return 0; 
#else 
return 1; 
#endif 
]],1) 
 
test_any([[ 
#if 0 
return 0; 
#elseif 0 
return 0; 
#elseif 1 
return 1; 
#elseif 0 
return 0; 
#elseif 0 
return 0; 
#else 
FEL 
#endif 
]],1) 
 
test_any([[ 
#if 0 
return 0; 
#elseif 1 
return 1; 
#else 
return 0; 
#endif 
]],1) 
 
test_any([[ 
#if 1 
return 1; 
#elseif 1 
return 0; 
#else 
return 0; 
#endif 
]],1) 
 
// #pragma 
// FIXME: add tests for real pragmas 
test_any([[ 
#pragma whatever 
return 1; 
]],1) 
 
// #include 
// FIXME add test for #include 
test_compile_any([[#include <simulate.h> 
]]) 
 
// #error 
test_compile_error([[ 
#error Gurgel 
]]) 
 
 
// foop 
define(do_test_foop,[[ 
test_eq($1 (17), !($2)) 
test_eq($1 (1.7), !($2-1)) 
test_eq($1 ("17"), !($2-2)) 
test_eq($1 (this_object()), !($2-3)) 
test_eq($1 (a), !($2-4)) // a is the test function 
test_eq($1 (({})), !($2-5)) 
test_eq($1 (([])), !($2-6)) 
test_eq($1 ((<>)), !($2-7)) 
test_eq($1 (object_program(this_object())), !($2-8)) 
]]) 
 
do_test_foop(intp,0) 
do_test_foop(floatp,1) 
do_test_foop(stringp,2) 
do_test_foop(objectp,3) 
do_test_foop(functionp,4) 
do_test_foop(arrayp,5) 
do_test_foop(mappingp,6) 
do_test_foop(multisetp,7) 
do_test_foop(programp,8) 
 
// add_constant 
test_do(add_constant("foobar",lambda() { return 1; })) 
test_any([[ 
#if efun(foobar) 
return 1; 
#else 
return 0; 
#endif 
]],1) 
test_eq(foobar(),1) 
test_do(add_constant("foobar")) 
test_any([[ 
#if efun(foobar) 
return 1; 
#else 
return 0; 
#endif 
]],0) 
 
// - aggregate 
test_true(arrayp(aggregate())) 
test_eq(sizeof(aggregate()),0) 
test_equal(aggregate(1,2,3,4),({1,2,3,4})) 
 
// - aggregate_multiset 
test_true(multisetp(aggregate_multiset())) 
 
// - aggregate_mapping 
test_true(multisetp(aggregate_multiset())) 
 
// - all_constants 
test_true(mappingp(all_constants())) 
test_true(all_constants()["all_constants"]) 
test_eq(all_constants()["all_constants"],all_constants) 
 
// - allocate 
test_true(arrayp(allocate(0))) 
test_equal(allocate(2),({0,0})) 
test_false(allocate(2)==({0,0})) 
 
// - backtrace 
test_true(arrayp(backtrace())) 
test_eq(backtrace()[-1][2],a) 
 
// - call_function 
test_eq(1,call_function(a)) 
test_eq(1,call_function(lambda(int a){ return a; },1)) 
test_eq(1,call_function(intp,1)) 
 
// - capitalize 
test_eq(String.capitalize("fubar"),"Fubar") 
test_eq(String.capitalize("FooBar"),"FooBar") 
test_eq(String.capitalize("-"),"-") 
 
// - clone 
// clone is already tested a lot by this script 
test_true(objectp(clone(compile_string("int foo() { return 17; }")))) 
test_eq(clone(compile_string("int foo() { return 17; }"))->foo(),17) 
 
// - combine_path 
test_eq([[combine_path("/foo/bar/gazonk/","..")]],"/foo/bar") 
test_eq([[combine_path("/.../","sune")]],"/.../sune") 
test_eq([[combine_path("/",".")]],"/") 
test_eq([[combine_path("/","foo/.../sune")]],"/foo/.../sune") 
test_eq([[combine_path("/./foo/bar//gazonk/","../")]],"/foo/bar/") 
test_eq([[combine_path("/","/foo/./bar/gazonk/..")]],"/foo/bar") 
test_eq([[combine_path("/","/foo/bar/gazonk/../../")]],"/foo/") 
test_eq([[combine_path("/","/foo//bar/gazonk/../..")]],"/foo") 
test_eq([[combine_path("/","/foo/bar/./gazonk/../../..")]],"/") 
test_eq([[combine_path("/","/foo/../bar//./gazonk/../..")]],"/") 
test_eq([[combine_path("/","/foo/././/bar/gazonk/../../../..")]],"/") 
test_eq([[combine_path("/","..")]],"/") 
test_eq([[combine_path("./","..")]],"..") 
test_eq([[combine_path("./.","..")]],"..") 
test_eq([[combine_path("/","../../foo")]],"/foo") 
test_eq([[combine_path("./foobar/.","..")]],".") 
test_eq([[combine_path("/","foo","bar","gazonk")]],"/foo/bar/gazonk") 
 
// - compile_file 
// FIXME: add tests for compile_file 
 
// - compile_string 
// see test for clone() 
 
// - copy_value 
test_eq(copy_value(1),1) 
test_eq(copy_value(""),"") 
test_eq(copy_value(1.0),1.0) 
test_eq(copy_value(this_object()),this_object()) 
test_eq(copy_value(a),a) 
define(do_test_copy_value,[[ 
test_any([[mixed x=$1; return x==x]],1) 
test_any([[mixed x=$1; return copy_value(x)!=x]],1) 
test_any([[mixed x=$1; return equal(copy_value(x),x)]],1)]]) 
do_test_copy_value( ({1}) ) 
do_test_copy_value( ([]) ) 
do_test_copy_value( (<>) ) 
do_test_copy_value( (< ([]), ({1}) ,"" , 1.0 >) ) 
 
// - crypt 
test_true(stringp(crypt("hej"))) 
test_true(crypt("hej",crypt("hej"))) 
test_false(crypt("hej","hej")) 
test_false(crypt("h","hej")) 
 
// - ctime 
test_true(stringp(ctime(0))) 
 
// - destruct 
// FIXME put tests for destruct here. 
test_do(add_constant("PROG",compile_string("int foo() { return 1; }"))); 
test_any([[object o=clone(PROG); destruct(o); return o]],0); 
test_any([[object o=clone(PROG); destruct(o); return objectp(o)]],0); 
test_any([[object *o=({clone(PROG)}); destruct(o[0]); return o-({0}) ]],({})); 
test_any([[mapping o=(["foo":clone(PROG)]); destruct(o["foo"]); return o["foo"]; ]],0); 
dnl test_any([[object t; mapping o=([t=clone(PROG):"foo"]); destruct(t); return sizeof(o)]],0); 
test_do([[object t,*o=({}); o+=({t=clone(PROG)}); destruct(t); o=({});]]); 
 
// - Array.diff 
test_equal(Array.diff(({ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }), 
                      ({ 6, 7, 8, 9, 3, 4, 5, 1, 2, 0 })), 
           ({ ({ ({ 0, 1, 2, 3, 4, 5 }), 
                 ({ 6, 7, 8, 9 }), ({}) }), 
              ({ ({}), ({ 6, 7, 8, 9 }), 
                 ({ 3, 4, 5, 1, 2, 0 }) }) })) 
test_equal(Array.diff(({ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }), 
                      ({ 9, 7, 8, 4, 5, 6, 0, 1, 2, 3 })), 
           ({ ({ ({}), ({ 0, 1, 2, 3 }), 
                 ({ 4, 5, 6, 7, 8, 9 }) }), 
              ({ ({ 9, 7, 8, 4, 5, 6 }), 
                 ({ 0, 1, 2, 3 }), ({}) }) })) 
test_equal(Array.diff("qadfgoksdfäojerjgöohjgdgkm"/"", 
                      "xadfgokälojeorjgöoyjgdgkmzzz"/""), 
           ({ ({ ({ "q" }), "adfgok"/"", "sdf"/"", ({ "ä" }), ({}), 
                 "oje"/"", ({}), "rjgöo"/"", ({ "h" }), "jgdgkm"/"", ({}) }), 
              ({ ({ "x" }), "adfgok"/"", ({}), ({ "ä" }), ({ "l" }), 
                 "oje"/"", ({ "o" }), "rjgöo"/"", ({ "y" }), "jgdgkm"/"", 
                 "zzz"/"" }) })) 
test_equal(Array.diff("123.org"/"","http://123.org/"/""), 
           ({ ({ ({}), "123.org"/"", ({}) }), 
              ({ "http://"/"", "123.org"/"", ({ "/" }) }) })) 
 
 
// - equal 
// equal is already tested by this script 
 
// - exit 
// FIXME put test for exit here 
 
// - explode 
test_equal(({"a","b","c",}), "anna bnna c"/"nna ") 
test_equal(({"","",}),"hej"/"hej") 
test_equal(({""}),""/"hej") 
 
// - fork() 
// FIXME: add tests for fork 
 
cond([[all_constants()->_verify_internals]], 
[[ 
  test_do(_verify_internals()) 
]]) 
 
// - function_name 
test_eq(function_name(a),"a") 
test_eq(function_name(function_name),0) 
 
// - function_object 
test_eq(function_object(a),this_object()) 
test_eq(function_name(function_object),0) 
 
// - get_function (actually in simulate.pike) 
test_eq(a,Simulate.get_function(this_object(),"a")) 
test_eq(a,this_object()->a) 
 
// - hash 
test_true(intp(hash("foo"))) 
test_true(intp(hash("foo",10))) 
test_true(hash("foo",10)<10) 
test_true(hash("bar",10)<10) 
test_true(hash("gazonk",10)<10) 
test_eq(hash("foobargazonk"),hash("foobargazonk")) 
 
// - implode 
test_eq([[({})*""]],"") 
test_eq([[("foo"/"o")*"o"]],"foo") 
test_eq([[({"foo","bar"})*"-"]],"foo-bar") 
test_eq([[({"foo",0,"bar"})*"-"]],"foo-bar") 
test_eq([[({1.0,"foo",0,"bar",this_object(),([])})*"-"]],"foo-bar") 
test_eq([[({"f","o","o"})*""]],"foo") 
 
// - indices 
test_equal(indices("foo"),({0,1,2})) 
test_equal(indices(({'f','o','o'})),({0,1,2})) 
test_equal(Array.sort_array(indices(([7:3,8:9,99:12]))),({7,8,99})) 
test_equal(Array.sort_array(indices((<7,8,99>))),({7,8,99})) 
test_equal(mkmultiset(indices(this_object())),(<"a","b">)) 
 
// - Array.longest_ordered_sequence 
test_equal(Array.longest_ordered_sequence("dfgaokäpojghadjjioijrgxcvb"/""), 
           ({ 0, 1, 2, 10, 11, 16, 18, 19, 20, 22 })); 
 
// - lower_case 
test_equal(lower_case("foo"),"foo") 
test_equal(lower_case("Foo"),"foo") 
test_equal(lower_case("Foo1234-*~\n"),"foo1234-*~\n") 
 
// - next_object 
test_true(objectp(next_object())) 
test_any(int e;object o=next_object(); for(e=0;e<1000 && o;e++) o=next_object(o); return o,0) 
 
// - object_program 
test_true(programp(object_program(this_object()))) 
 
// - query_num_arg 
test_eq(lambda(int ... q) { return query_num_arg(); }(),0) 
test_eq(lambda(int ... q) { return query_num_arg(); }(1),1) 
test_eq(lambda(int ... q) { return query_num_arg(); }(1,1),2) 
test_eq(lambda(int ... q) { return query_num_arg(); }(1,1,1),3) 
test_eq(lambda(int ... q) { return query_num_arg(); }(1,1,1,1),4) 
 
// - random 
test_any([[int e,d;for(e=0;e<1000;e++){d=random(10); if(d<0 || d>=10) return 0;} return 1]],1) 
 
// random_seed 
test_do(int p; foreach(({1,2,3,4,5}),p) random_seed(p)) 
test_eq([[random_seed(17),random(20000)]],[[random_seed(17),random(20000)]]) 
test_eq([[random_seed(18),random(20000)]],[[random_seed(18),random(20000)]]) 
test_eq([[random_seed(19),random(20000)]],[[random_seed(19),random(20000)]]) 
 
// - replace 
test_eq(replace("foobargazonk","o","-"),"f--bargaz-nk") 
test_eq(replace("foobargazonk",({"o","a"}),({"()","<>"})),"f()()b<>rg<>z()nk") 
test_eq(replace("f--barf--",({"f--","f--bar"}),({"f--bar","f--"})),"f--f--bar") 
test_eq(replace("f--barf--",({"f--bar","f--"}),({"f--","f--bar"})),"f--f--bar") 
test_equal(replace(({1,2,3,4,5,1,2,3,4}),3,-1),({1,2,-1,4,5,1,2,-1,4})) 
test_equal(replace(([1:2,3:4,5:1,2:3]),3,-1),([1:2,3:4,5:1,2:-1])) 
 
// - reverse 
test_eq(reverse("reverse"),"esrever") 
test_eq(reverse(""),"") 
test_eq(reverse("a"),"a") 
test_equal(reverse(({1,5,9})),({9,5,1})) 
test_equal(reverse(0x12345678),0x1e6a2c48) 
 
// - rusage 
test_true(arrayp(rusage())) 
test_true(sizeof(rusage())>0) 
 
// - search 
test_eval_error(search("foolbar","o",-10)) 
test_eval_error(search("foolbar","o",2983742)) 
test_eq(search("foolbar","gazonk"),-1) 
test_eq(search("qowiueproqiuweproiwqueoplkjljlklksjjriwueproiuwerowieu","lkjljlklksjj"),24) 
test_eq(search("lkjljlklksjjriwueproiuwerlskjdvlaskjfowieu","lkjljlklksjj"),0) 
test_eq(search("aaaaaaaaaaaaaaaaaaaaaaaalkjljlklksjj","lkjljlklksjj"),24) 
test_eq(search("foobargazonk","oo"),1) 
test_eq(search("foobargazonk","o",3),9) 
test_eq(search("foobargazonk","o",9),9) 
test_eq(search("foobargazonk","o",10),-1) 
test_eq(search("foobargazonk","x",9),-1) 
test_eq(search(({56,8,2,6,2,7,3,56,7}),8),1) 
test_eq(search(({56,8,2,6,2,7,3,56,7}),56,0),0) 
test_eq(search(({56,8,2,6,2,7,3,56,7}),56,1),7) 
test_eq(search(({56,8,2,6,2,7,3,56,7}),56,7),7) 
test_eq(search(({56,8,2,6,2,7,3,56,7}),56,8),-1) 
test_eq(search(({"foo"}),"foo"),0) 
test_eq(search("fo-obar|gazonk"/"|","fo-obar"),0) 
test_eq(search("fo-obar|gazonk"/"|","gazonk"),1) 
test_eq(search(([1:2,3:4,5:6,7:8]),4),3) 
test_true(zero_type(search(([1:2,3:4,5:6,7:8]),1))) 
test_eq(search(([1:2,3:4,5:6,7:8]),8),7) 
 
// test large searches (find string, size, pattern) 
define(test_search,[[ 
test_eq(search(sprintf($1+"%'"+$3+"'*n",$2),$1),0) 
test_eq(search(sprintf("%'"+$3+"'*n" ,$2),$1),-1) 
test_eq(search(sprintf("%'"+$3+"'*n"+$1,$2),$1),$2) 
test_eq(search(sprintf("%'"+$3+"'*n"+$1+"%'"+$3+"'*n",$2,$2),$1),$2) 
]]) 
 
define(test_search2,[[dnl 
test_search($1,$2,$3) 
test_search($1,$2+1,$3) 
test_search($1,$2+2,$3) 
test_search($1,$2+3,$3) 
test_search($1,$2+4,$3) 
test_search($1,$2+5,$3) 
]]) 
 
define(test_search3,[[dnl 
test_search2($1,10,$2) 
test_search2($1,1000,$2) 
test_search2($1,100000,$2) 
]]) 
 
define(test_search4,[[dnl 
test_search3($1,"+-*") 
test_search3($1,($1[..strlen($1)-2])) 
test_search3($1,($1[..strlen($1)-3])) 
test_search3($1,($1[1..])) 
]]) 
 
dnl some m4's don't handle 8 bit characters... 
test_search4("SUNE") 
test_search4("kapit\344l>") 
test_search4("-------------------+") 
test_search4("\345-------------------") 
test_search4(sprintf("%'argel-bargel glop-glyf?'2000n")) 
 
// - sizeof 
test_eq(sizeof("felbar"),6) 
test_eq(sizeof(({"fulbar","gazonk",7})),3) 
test_eq(sizeof(([8:3,6:6,7:0])),3) 
test_eq(sizeof((<8,7,6,5,4,7>)),6) 
 
// - sleep 
test_do(sleep(1)) 
test_do(sleep(0.5)) 
test_any([[int x=time(); sleep(2); return x!=time()]],1) 
test_any([[int x=time(); sleep(2); return x!=time()]],1) 
 
// - sum 
test_eq(`+(1,1),2) 
test_eq(`+(1,-2),-1) 
test_eq(`+(-2,-2),-4) 
test_eq(`+("hi","there"),"hithere") 
test_eq(`+("human","number",666),"humannumber666") 
test_eq(`+("human","number",666),"humannumber666") 
test_eq(`+("human","number",666),"humannumber666") 
test_eq(`+("human","number",666,111),"humannumber666111") 
test_eq(`+("humannumber",`+(666+111)),"humannumber777") 
test_eq(`+("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","x","y"),"abcdefghijklmnopqrstuvxy") 
test_eq(`+(1.0+1.0),2.0) 
test_eq(`+(1.0,-1.0),0.0) 
test_eq(`+(-1.0,-1.0),-2.0) 
test_equal(`+(({1,2,3}),({4,5,6})),({1,2,3,4,5,6})) 
test_equal(`+((<1,2,3,4>),(<4,5,6>)),(<1,2,3,4,4,5,6>)) 
test_equal(`+(([0:1,3:6]),([5:2,3:6])),([0:1,3:6,3:6,5:2])) 
 
// - this_object 
test_true(objectp(this_object())) 
 
// - throw 
test_eq(20,catch(throw(a()))) 
 
// - catch compile-errors 
test_any([[ master()->set_inhibit_compile_errors(lambda(){});mixed res = catch{compile_string("dfasfqw123");};master()->set_inhibit_compile_errors(0); return arrayp(res); ]], 1) 
 
// catch 
test_false([[class X { string test(string foo) { catch { return lower_case(foo); }; return foo; }}()->test(0); ]]) 
 
// - time 
test_true(intp(time())) 
test_true(intp(time(1))) 
test_true(floatp(time(2))) 
 
// - trace 
test_do(trace(0)) 
test_eq(trace(0),0) 
 
// - upper_case 
test_equal(upper_case("fooq"),"FOOQ") 
test_equal(upper_case("FooR"),"FOOR") 
test_equal(upper_case("Foo1234-*~\n"),"FOO1234-*~\n") 
 
// - values 
test_equal(values("foo"),({'f','o','o'})) 
test_equal(values(({'f','o','o'})),({'f','o','o'})) 
test_equal(Array.sort_array(values(([7:3,8:9,99:12]))),({3,9,12})) 
test_equal(values((<7,8,99>)),({1,1,1})) 
test_equal(mkmultiset(values(this_object())),(<a,b>)) 
 
// - zero_type 
test_eq(zero_type(0),0) 
test_eq(zero_type(([])[7]),1) 
 
test_program(int b=10; mixed a() { return 1; }) 
test_program(mixed b=10; mixed a() { return 1;}) 
test_define_program(test,[[int q,w,e,r,t; mixed foo() { return 10; }]]) 
 
test_program(inherit test; mixed a() { return foo()==10; }) 
test_program(inherit test; mixed a() { return test::foo()==10; }) 
test_program(inherit test : bar; mixed a() { return bar::foo()==10; }) 
 
test_define_program(test2,[[int z,x,c,v,b; mixed bar() { return 11; }]]) 
test_program(inherit test; inherit test2; mixed a() { return foo()==10 && bar()==11; }) 
test_program(inherit test2; inherit test; mixed a() { return foo()==10 && bar()==11; }) 
 
test_define_program(test,[[int q,w,e,r; mixed t; mixed getw() { return w; } void setw(int _) { w=_; }]]) 
test_define_program(test2,[[int z,x,c,v,b; mixed getb() { return b; } void setb(int _) { b=_; }]]) 
 
test_program(inherit test; inherit test2; mixed a() { w=20; b=22; return getw()==20 && getb()==22; }) 
test_program(inherit test; inherit test2; mixed a() { setw(20); setb(22); return w==20 && b==22; }) 
test_program(inherit test2; inherit test; mixed a() { w=20; b=22; return getw()==20 && getb()==22; }) 
test_program(inherit test2; inherit test; mixed a() { setw(20); setb(22); return w==20 && b==22; }) 
 
test_eval_error(clone(class c{int i;void foo(){ destruct(this_object());i=0;}})->foo()) 
 
// Pike modules 
 
// LR 
test_true(LR.parser) 
test_true(LR.Grammar_parser) 
test_program([[ object(LR.parser) p=LR.Grammar_parser.make_parser("foo : bar;foo : foo bar;bar : \"a\";"); int pos; array(string) data="aaaaaaaaa"/""; string scan() { if (pos < sizeof(data)) return(data[pos++]); else return ""; } int a() { return(p->parse(scan) == "a"); }]]) 
 
// - Table.pmod 
test_true(ADT.Table.table) 
test_true(ADT.Table.ASCII) 
test_true(ADT.Table.table( ({ ({ "a", "b", 42 }), ({ "c", "b", 41 }), ({ "a", "a", 76 }) }), ({ "X", "Y", "z" }))->select("x", 2)->sum("Z")->distinct(0)->rsort("X")->rename(0, "fOo")->sort("foO")->cast("array"), ({ ({ "a", 118 }), ({ "c", 41 }) })) 
 
// - Process 
test_true(Process) 
test_true(Process.popen) 
test_true(Process.spawn) 
test_true(Process.system) 
test_true(Process.create_process) 
test_false([[Process.system(RUNPIKE +" -e 'exit(0)'")]]) 
test_true([[Process.system(RUNPIKE+" -e 'exit(1)'")]]) 
test_any([[object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(2)"})); sleep(10); return p->wait()]],2) 
test_eq([[Process.popen(RUNPIKE+" -e 'write(\"test\");'")]],"test") 
test_any([[object o=Stdio.File(); object o2=o->pipe(Stdio.PROP_IPC); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.stdin->read(5)==\"hello\")"}),(["stdin":o])); o2->write("hello"); destruct(o); destruct(o2); return p->wait()]],1) 
test_any([[object o=Stdio.File(); object o2=o->pipe(Stdio.PROP_IPC); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.stdin->read(1000)==\"hello\")"}),(["stdin":o])); o2->write("hello"); destruct(o); destruct(o2); return p->wait()]],1) 
test_any([[object o=Stdio.Fd();   object o2=o->pipe(Stdio.PROP_IPC); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.stdin->read(1000)==\"hello\")"}),(["stdin":o])); o2->write("hello"); destruct(o); destruct(o2); return p->wait()]],1) 
test_any([[object o=Stdio.Fd();   object o2=o->pipe(Stdio.PROP_IPC); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.stdin->read(1000)==\"hello\")"}),(["stdin":o])); o2->write("hello"); destruct(o2); return p->wait()]],1) 
test_any([[object o=Stdio.Fd();   object o2=o->pipe(Stdio.PROP_IPC); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.stdin->read(1000)==\"hello\")"}),(["stdin":o])); o2->write("hello"); o2=0; return p->wait()]],1) 
 
test_any([[object o=Stdio.Fd();   object o2=o->pipe(); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.stdin->read(5)==\"hello\")"}),(["stdin":o])); o2->write("hello"); destruct(o); destruct(o2); return p->wait()]],1) 
test_any([[object o=Stdio.Fd();   object o2=o->pipe(); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.stdin->read(1000)==\"hello\")"}),(["stdin":o])); o2->write("hello"); destruct(o); destruct(o2); return p->wait()]],1) 
test_any([[object o=Stdio.Fd();   object o2=o->pipe(); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.File(\"stdin\")->read(1000)==\"hello\")"}),(["stdin":o])); o2->write("hello"); destruct(o); destruct(o2); return p->wait()]],1) 
test_any([[object o=Stdio.File(); object o2=o->pipe(); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.File(\"stdin\")->read(1000)==\"hello\")"}),(["stdin":o])); o2->write("hello"); destruct(o); destruct(o2); return p->wait()]],1) 
test_any([[object o=Stdio.File(); object o2=o->pipe(Stdio.PROP_IPC); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.stdin->read(1000)==\"hello\")"}),(["stdin":o])); o2->write("hello"); destruct(o); destruct(o2); return p->wait()]],1) 
test_any([[object o=Stdio.File(); object o2=o->pipe(Stdio.PROP_BIDIRECTIONAL); object p=Process.create_process(Process.split_quoted_string(RUNPIKE)+({"-e","exit(Stdio.stdin->read(1000)==\"hello\")"}),(["stdin":o2])); o->write("hello"); destruct(o); destruct(o2); return p->wait()]],1) 
 
 
 
test_equal(Array.splice(({7,8,99}),({"h","h",99})), 
        ({7,"h",8,"h",99,99})) 
test_equal(Array.splice(({7,8}),({"h","h",99})), 
        ({7,"h",8,"h"})) 
test_equal(Array.splice(({7,8,99}),({"h","h",99}),({"g",({"fg"}),97})), 
        ({7,"h","g",8,"h",({"fg"}),99,99,97})) 
test_equal(Array.splice(({7,"foo"})), 
        ({7,"foo"})) 
test_equal(Array.splice(), 
        ({})) 
test_equal(Array.splice(({})), 
        ({})) 
 
test_equal(Array.everynth("0123456789"/""), 
  ({ "0", "2", "4", "6", "8"})) 
test_equal(Array.everynth("0123456789"/"",3), 
  ({ "0", "3", "6", "9"})) 
test_equal(Array.everynth("0123456789"/"",3,4), 
  ({ "4", "7"})) 
 
 
test_equal(Array.transpose( ({ ({ 1,2,3}), ({4,5,6}) }) ), 
        ({ ({1,4}), ({2,5}), ({3,6}) })) 
 
test_true(!Yabu.test()->main(1,({"test"}))) 
test_do([[ 
  string s; 
  for(s="foobar";strlen(s)<78;s+=s) 
  { 
    for(int e=0;e<strlen(s);e++) 
    { 
      s[e]++; 
    } 
  } 
]]) 
 
test_any([[string s="foo"; s[2]='t'; s[0]--; return s;]],"eot") 
 
cond([[all_constants()->_verify_internals]], 
[[ 
  test_do(_verify_internals()) 
]])