Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Merge over testing improvements from the TIP 475 work. Test files string.test and stringComp.test had become out of sync. Use one file to maintain even coverage. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | core-8-branch |
Files: | files | file ages | folders |
SHA3-256: |
e1141b4ed57a46bfc7fe6b0b062ce137 |
User & Date: | dgp 2018-03-20 19:25:54 |
Context
2018-03-20
| ||
19:54 | TIP 503 implementation. check-in: ae29ed9c7f user: dgp tags: core-8-branch | |
19:25 | Merge over testing improvements from the TIP 475 work. Test files string.test and stringComp.test ha... check-in: e1141b4ed5 user: dgp tags: core-8-branch | |
16:10 | Test and fix for botch in binary string replace. check-in: a0dec2ad25 user: dgp tags: core-8-branch | |
Changes
Changes to tests/basic.test.
︙ | ︙ | |||
666 667 668 669 670 671 672 | set l1 [list a {b b} c d] set l2 [list e f {g g} h] proc l3 {} { list i j k {l l} } # Do all tests once byte compiled and once with direct string evaluation | | | 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 | set l1 [list a {b b} c d] set l2 [list e f {g g} h] proc l3 {} { list i j k {l l} } # Do all tests once byte compiled and once with direct string evaluation foreach noComp {0 1} { if $noComp { interp alias {} run {} testevalex set constraints testevalex } else { interp alias {} run {} if 1 set constraints {} |
︙ | ︙ |
Changes to tests/compile.test.
︙ | ︙ | |||
495 496 497 498 499 500 501 | test compile-15.4 {proper TCL_RETURN code from [return]} { apply {{} {catch {return [info library]}}} } 2 test compile-15.5 {proper TCL_RETURN code from [return]} { apply {{} {catch {set a 1}; return}} } "" | > | | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 | test compile-15.4 {proper TCL_RETURN code from [return]} { apply {{} {catch {return [info library]}}} } 2 test compile-15.5 {proper TCL_RETURN code from [return]} { apply {{} {catch {set a 1}; return}} } "" # Do all tests once byte compiled and once with direct string evaluation foreach noComp {0 1} { if $noComp { interp alias {} run {} testevalex set constraints testevalex } else { interp alias {} run {} if 1 set constraints {} |
︙ | ︙ |
Changes to tests/string.test.
︙ | ︙ | |||
18 19 20 21 22 23 24 25 26 27 | } ::tcltest::loadTestedCommands catch [list package require -exact Tcltest [info patchlevel]] # Helper commands to test various optimizations, code paths, and special cases. proc makeByteArray {s} {binary format a* $s} # Some tests require the testobj command | > > > | | > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > | | | | > > > > > > | > > > | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > | | | | > | > > | | | > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | < | | < > > > > > > > > > | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > | | | | | | | | > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | | > | > > | > | > > > > > > > | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > | > > | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 | } ::tcltest::loadTestedCommands catch [list package require -exact Tcltest [info patchlevel]] # Helper commands to test various optimizations, code paths, and special cases. proc makeByteArray {s} {binary format a* $s} proc makeUnicode {s} {lindex [regexp -inline .* $s] 0} proc makeList {args} {return $args} proc makeShared {s} {uplevel 1 [list lappend copy $s]; return $s} # Some tests require the testobj command testConstraint testobj [expr {[info commands testobj] ne {}}] testConstraint testindexobj [expr {[info commands testindexobj] ne {}}] testConstraint testevalex [expr {[info commands testevalex] ne {}}] testConstraint fullutf [expr {[format %c 0x010000] != "\ufffd"}] # Used for constraining memory leak tests testConstraint memory [llength [info commands memory]] if {[testConstraint memory]} { proc getbytes {} { set lines [split [memory info] \n] return [lindex $lines 3 3] } proc leaktest {script {iterations 3}} { set end [getbytes] for {set i 0} {$i < $iterations} {incr i} { uplevel 1 $script set tmp $end set end [getbytes] } return [expr {$end - $tmp}] } } proc representationpoke s { set r [::tcl::unsupported::representation $s] list [lindex $r 3] [string match {*, string representation "*"} $r] } foreach noComp {0 1} { if {$noComp} { if {[info commands testevalex] eq {}} { test string-0.1.$noComp "show testevalex availability" {testevalex} {list} {} continue } interp alias {} run {} testevalex set constraints testevalex } else { interp alias {} run {} try set constraints {} } test string-1.1.$noComp {error conditions} { list [catch {run {string gorp a b}} msg] $msg } {1 {unknown or ambiguous subcommand "gorp": must be bytelength, cat, compare, equal, first, index, is, last, length, map, match, range, repeat, replace, reverse, tolower, totitle, toupper, trim, trimleft, trimright, wordend, or wordstart}} test string-1.2.$noComp {error conditions} { list [catch {run {string}} msg] $msg } {1 {wrong # args: should be "string subcommand ?arg ...?"}} test stringComp-1.3.$noComp {error condition - undefined method during compile} { # We don't want this to complain about 'never' because it may never # be called, or string may get redefined. This must compile OK. proc foo {str i} { if {"yes" == "no"} { string never called but complains here } string index $str $i } foo abc 0 } a test string-2.1.$noComp {string compare, too few args} { list [catch {run {string compare a}} msg] $msg } {1 {wrong # args: should be "string compare ?-nocase? ?-length int? string1 string2"}} test string-2.2.$noComp {string compare, bad args} { list [catch {run {string compare a b c}} msg] $msg } {1 {bad option "a": must be -nocase or -length}} test string-2.3.$noComp {string compare, bad args} { list [catch {run {string compare -length -nocase str1 str2}} msg] $msg } {1 {expected integer but got "-nocase"}} test string-2.4.$noComp {string compare, too many args} { list [catch {run {string compare -length 10 -nocase str1 str2 str3}} msg] $msg } {1 {wrong # args: should be "string compare ?-nocase? ?-length int? string1 string2"}} test string-2.5.$noComp {string compare with length unspecified} { list [catch {run {string compare -length 10 10}} msg] $msg } {1 {wrong # args: should be "string compare ?-nocase? ?-length int? string1 string2"}} test string-2.6.$noComp {string compare} { run {string compare abcde abdef} } -1 test string-2.7.$noComp {string compare, shortest method name} { run {string co abcde ABCDE} } 1 test string-2.8.$noComp {string compare} { run {string compare abcde abcde} } 0 test string-2.9.$noComp {string compare with length} { run {string compare -length 2 abcde abxyz} } 0 test string-2.10.$noComp {string compare with special index} { list [catch {run {string compare -length end-3 abcde abxyz}} msg] $msg } {1 {expected integer but got "end-3"}} test string-2.11.$noComp {string compare, unicode} { run {string compare ab\u7266 ab\u7267} } -1 test string-2.11.1.$noComp {string compare, unicode} { run {string compare \334 \u00dc} } 0 test string-2.11.2.$noComp {string compare, unicode} { run {string compare \334 \u00fc} } -1 test string-2.11.3.$noComp {string compare, unicode} { run {string compare \334\334\334\374\374 \334\334\334\334\334} } 1 test string-2.12.$noComp {string compare, high bit} { # This test will fail if the underlying comparaison # is using signed chars instead of unsigned chars. # (like SunOS's default memcmp thus the compat/memcmp.c) run {string compare "\x80" "@"} # Nb this tests works also in utf8 space because \x80 is # translated into a 2 or more bytelength but whose first byte has # the high bit set. } 1 test string-2.13.$noComp {string compare -nocase} { run {string compare -nocase abcde abdef} } -1 test string-2.13.1.$noComp {string compare -nocase} { run {string compare -nocase abcde Abdef} } -1 test string-2.14.$noComp {string compare -nocase} { run {string compare -nocase abcde ABCDE} } 0 test string-2.15.$noComp {string compare -nocase} { run {string compare -nocase abcde abcde} } 0 test string-2.15.1.$noComp {string compare -nocase} { run {string compare -nocase \334 \u00dc} } 0 test string-2.15.2.$noComp {string compare -nocase} { run {string compare -nocase \334\334\334\374\u00fc \334\334\334\334\334} } 0 test string-2.16.$noComp {string compare -nocase with length} { run {string compare -length 2 -nocase abcde Abxyz} } 0 test string-2.17.$noComp {string compare -nocase with length} { run {string compare -nocase -length 3 abcde Abxyz} } -1 test string-2.18.$noComp {string compare -nocase with length <= 0} { run {string compare -nocase -length -1 abcde AbCdEf} } -1 test string-2.19.$noComp {string compare -nocase with excessive length} { run {string compare -nocase -length 50 AbCdEf abcde} } 1 test string-2.20.$noComp {string compare -len unicode} { # These are strings that are 6 BYTELENGTH long, but the length # shouldn't make a different because there are actually 3 CHARS long run {string compare -len 5 \334\334\334 \334\334\374} } -1 test string-2.21.$noComp {string compare -nocase with special index} { list [catch {run {string compare -nocase -length end-3 Abcde abxyz}} msg] $msg } {1 {expected integer but got "end-3"}} test string-2.22.$noComp {string compare, null strings} { run {string compare "" ""} } 0 test string-2.23.$noComp {string compare, null strings} { run {string compare "" foo} } -1 test string-2.24.$noComp {string compare, null strings} { run {string compare foo ""} } 1 test string-2.25.$noComp {string compare -nocase, null strings} { run {string compare -nocase "" ""} } 0 test string-2.26.$noComp {string compare -nocase, null strings} { run {string compare -nocase "" foo} } -1 test string-2.27.$noComp {string compare -nocase, null strings} { run {string compare -nocase foo ""} } 1 test string-2.28.$noComp {string compare with length, unequal strings} { run {string compare -length 2 abc abde} } 0 test string-2.29.$noComp {string compare with length, unequal strings} { run {string compare -length 2 ab abde} } 0 test string-2.30.$noComp {string compare with NUL character vs. other ASCII} { # Be careful here, since UTF-8 rep comparison with memcmp() of # these puts chars in the wrong order run {string compare \x00 \x01} } -1 test string-2.31.$noComp {string compare, high bit} { run {string compare "a\x80" "a@"} } 1 test string-2.32.$noComp {string compare, high bit} { run {string compare "a\x00" "a\x01"} } -1 test string-2.33.$noComp {string compare, high bit} { run {string compare "\x00\x00" "\x00\x01"} } -1 test string-2.34.$noComp {string compare, binary equal} { run {string compare [binary format a100 0] [binary format a100 0]} } 0 test string-2.35.$noComp {string compare, binary neq} { run {string compare [binary format a100a 0 1] [binary format a100a 0 0]} } 1 test string-2.36.$noComp {string compare, binary neq unequal length} { run {string compare [binary format a20a 0 1] [binary format a100a 0 0]} } 1 # only need a few tests on equal, since it uses the same code as # string compare, but just modifies the return output test string-3.1.$noComp {string equal} { run {string equal abcde abdef} } 0 test string-3.2.$noComp {string equal} { run {string e abcde ABCDE} } 0 test string-3.3.$noComp {string equal} { run {string equal abcde abcde} } 1 test string-3.4.$noComp {string equal -nocase} { run {string equal -nocase \334\334\334\334\374\374\374\374 \334\334\334\334\334\334\334\334} } 1 test string-3.5.$noComp {string equal -nocase} { run {string equal -nocase abcde abdef} } 0 test string-3.6.$noComp {string equal -nocase} { run {string eq -nocase abcde ABCDE} } 1 test string-3.7.$noComp {string equal -nocase} { run {string equal -nocase abcde abcde} } 1 test string-3.8.$noComp {string equal with length, unequal strings} { run {string equal -length 2 abc abde} } 1 test string-3.9.$noComp {string equal, too few args} { list [catch {run {string equal a}} msg] $msg } {1 {wrong # args: should be "string equal ?-nocase? ?-length int? string1 string2"}} test string-3.10.$noComp {string equal, bad args} { list [catch {run {string equal a b c}} msg] $msg } {1 {bad option "a": must be -nocase or -length}} test string-3.11.$noComp {string equal, bad args} { list [catch {run {string equal -length -nocase str1 str2}} msg] $msg } {1 {expected integer but got "-nocase"}} test string-3.12.$noComp {string equal, too many args} { list [catch {run {string equal -length 10 -nocase str1 str2 str3}} msg] $msg } {1 {wrong # args: should be "string equal ?-nocase? ?-length int? string1 string2"}} test string-3.13.$noComp {string equal with length unspecified} { list [catch {run {string equal -length 10 10}} msg] $msg } {1 {wrong # args: should be "string equal ?-nocase? ?-length int? string1 string2"}} test string-3.14.$noComp {string equal with length} { run {string equal -length 2 abcde abxyz} } 1 test string-3.15.$noComp {string equal with special index} { list [catch {run {string equal -length end-3 abcde abxyz}} msg] $msg } {1 {expected integer but got "end-3"}} test string-3.16.$noComp {string equal, unicode} { run {string equal ab\u7266 ab\u7267} } 0 test string-3.17.$noComp {string equal, unicode} { run {string equal \334 \u00dc} } 1 test string-3.18.$noComp {string equal, unicode} { run {string equal \334 \u00fc} } 0 test string-3.19.$noComp {string equal, unicode} { run {string equal \334\334\334\374\374 \334\334\334\334\334} } 0 test string-3.20.$noComp {string equal, high bit} { # This test will fail if the underlying comparaison # is using signed chars instead of unsigned chars. # (like SunOS's default memcmp thus the compat/memcmp.c) run {string equal "\x80" "@"} # Nb this tests works also in utf8 space because \x80 is # translated into a 2 or more bytelength but whose first byte has # the high bit set. } 0 test string-3.21.$noComp {string equal -nocase} { run {string equal -nocase abcde Abdef} } 0 test string-3.22.$noComp {string equal, -nocase unicode} { run {string equal -nocase \334 \u00dc} } 1 test string-3.23.$noComp {string equal, -nocase unicode} { run {string equal -nocase \334\334\334\374\u00fc \334\334\334\334\334} } 1 test string-3.24.$noComp {string equal -nocase with length} { run {string equal -length 2 -nocase abcde Abxyz} } 1 test string-3.25.$noComp {string equal -nocase with length} { run {string equal -nocase -length 3 abcde Abxyz} } 0 test string-3.26.$noComp {string equal -nocase with length <= 0} { run {string equal -nocase -length -1 abcde AbCdEf} } 0 test string-3.27.$noComp {string equal -nocase with excessive length} { run {string equal -nocase -length 50 AbCdEf abcde} } 0 test string-3.28.$noComp {string equal -len unicode} { # These are strings that are 6 BYTELENGTH long, but the length # shouldn't make a different because there are actually 3 CHARS long run {string equal -len 5 \334\334\334 \334\334\374} } 0 test string-3.29.$noComp {string equal -nocase with special index} { list [catch {run {string equal -nocase -length end-3 Abcde abxyz}} msg] $msg } {1 {expected integer but got "end-3"}} test string-3.30.$noComp {string equal, null strings} { run {string equal "" ""} } 1 test string-3.31.$noComp {string equal, null strings} { run {string equal "" foo} } 0 test string-3.32.$noComp {string equal, null strings} { run {string equal foo ""} } 0 test string-3.33.$noComp {string equal -nocase, null strings} { run {string equal -nocase "" ""} } 1 test string-3.34.$noComp {string equal -nocase, null strings} { run {string equal -nocase "" foo} } 0 test string-3.35.$noComp {string equal -nocase, null strings} { run {string equal -nocase foo ""} } 0 test string-3.36.$noComp {string equal with NUL character vs. other ASCII} { # Be careful here, since UTF-8 rep comparison with memcmp() of # these puts chars in the wrong order run {string equal \x00 \x01} } 0 test string-3.37.$noComp {string equal, high bit} { run {string equal "a\x80" "a@"} } 0 test string-3.38.$noComp {string equal, high bit} { run {string equal "a\x00" "a\x01"} } 0 test string-3.39.$noComp {string equal, high bit} { run {string equal "a\x00\x00" "a\x00\x01"} } 0 test string-3.40.$noComp {string equal, binary equal} { run {string equal [binary format a100 0] [binary format a100 0]} } 1 test string-3.41.$noComp {string equal, binary neq} { run {string equal [binary format a100a 0 1] [binary format a100a 0 0]} } 0 test string-3.42.$noComp {string equal, binary neq inequal length} { run {string equal [binary format a20a 0 1] [binary format a100a 0 0]} } 0 test string-4.1.$noComp {string first, too few args} { list [catch {run {string first a}} msg] $msg } {1 {wrong # args: should be "string first needleString haystackString ?startIndex?"}} test string-4.2.$noComp {string first, bad args} { list [catch {run {string first a b c}} msg] $msg } {1 {bad index "c": must be integer?[+-]integer? or end?[+-]integer?}} test string-4.3.$noComp {string first, too many args} { list [catch {run {string first a b 5 d}} msg] $msg } {1 {wrong # args: should be "string first needleString haystackString ?startIndex?"}} test string-4.4.$noComp {string first} { run {string first bq abcdefgbcefgbqrs} } 12 test string-4.5.$noComp {string first} { run {string fir bcd abcdefgbcefgbqrs} } 1 test string-4.6.$noComp {string first} { run {string f b abcdefgbcefgbqrs} } 1 test string-4.7.$noComp {string first} { run {string first xxx x123xx345xxx789xxx012} } 9 test string-4.8.$noComp {string first} { run {string first "" x123xx345xxx789xxx012} } -1 test string-4.9.$noComp {string first, unicode} { run {string first x abc\u7266x} } 4 test string-4.10.$noComp {string first, unicode} { run {string first \u7266 abc\u7266x} } 3 test string-4.11.$noComp {string first, start index} { run {string first \u7266 abc\u7266x 3} } 3 test string-4.12.$noComp {string first, start index} { run {string first \u7266 abc\u7266x 4} } -1 test string-4.13.$noComp {string first, start index} { run {string first \u7266 abc\u7266x end-2} } 3 test string-4.14.$noComp {string first, negative start index} { run {string first b abc -1} } 1 test string-4.15.$noComp {string first, ability to two-byte encoded utf-8 chars} { # Test for a bug in Tcl 8.3 where test for all-single-byte-encoded # strings was incorrect, leading to an index returned by [string first] # which pointed past the end of the string. set uchar \u057e ;# character with two-byte encoding in utf-8 run {string first % %#$uchar$uchar#$uchar$uchar#% 3} } 8 test string-4.16.$noComp {string first, normal string vs pure unicode string} { set s hello regexp ll $s m # Representation checks are canaries run {list [representationpoke $s] [representationpoke $m] \ [string first $m $s]} } {{string 1} {string 0} 2} test string-5.1.$noComp {string index} { list [catch {run {string index}} msg] $msg } {1 {wrong # args: should be "string index string charIndex"}} test string-5.2.$noComp {string index} { list [catch {run {string index a b c}} msg] $msg } {1 {wrong # args: should be "string index string charIndex"}} test string-5.3.$noComp {string index} { run {string index abcde 0} } a test string-5.4.$noComp {string index} { run {string ind abcde 4} } e test string-5.5.$noComp {string index} { run {string index abcde 5} } {} test string-5.6.$noComp {string index} { list [catch {run {string index abcde -10}} msg] $msg } {0 {}} test string-5.7.$noComp {string index} { list [catch {run {string index a xyz}} msg] $msg } {1 {bad index "xyz": must be integer?[+-]integer? or end?[+-]integer?}} test string-5.8.$noComp {string index} { run {string index abc end} } c test string-5.9.$noComp {string index} { run {string index abc end-1} } b test string-5.10.$noComp {string index, unicode} { run {string index abc\u7266d 4} } d test string-5.11.$noComp {string index, unicode} { run {string index abc\u7266d 3} } \u7266 test string-5.12.$noComp {string index, unicode over char length, under byte length} { run {string index \334\374\334\374 6} } {} test string-5.13.$noComp {string index, bytearray object} { run {string index [binary format a5 fuz] 0} } f test string-5.14.$noComp {string index, bytearray object} { run {string index [binary format I* {0x50515253 0x52}] 3} } S test string-5.15.$noComp {string index, bytearray object} { set b [binary format I* {0x50515253 0x52}] set i1 [run {string index $b end-6}] set i2 [run {string index $b 1}] run {string compare $i1 $i2} } 0 test string-5.16.$noComp {string index, bytearray object with string obj shimmering} { set str "0123456789\x00 abcdedfghi" binary scan $str H* dump run {string compare [run {string index $str 10}] \x00} } 0 test string-5.17.$noComp {string index, bad integer} -body { list [catch {run {string index "abc" 0o8}} msg] $msg } -match glob -result {1 {*invalid octal number*}} test string-5.18.$noComp {string index, bad integer} -body { list [catch {run {string index "abc" end-0o0289}} msg] $msg } -match glob -result {1 {*invalid octal number*}} test string-5.19.$noComp {string index, bytearray object out of bounds} { run {string index [binary format I* {0x50515253 0x52}] -1} } {} test string-5.20.$noComp {string index, bytearray object out of bounds} { run {string index [binary format I* {0x50515253 0x52}] 20} } {} proc largest_int {} { # This will give us what the largest valid int on this machine is, # so we can test for overflow properly below on >32 bit systems set int 1 set exp 7; # assume we get at least 8 bits while {wide($int) > 0} { set int [expr {wide(1) << [incr exp]}] } return [expr {$int-1}] } test string-6.1.$noComp {string is, too few args} { list [catch {run {string is}} msg] $msg } {1 {wrong # args: should be "string is class ?-strict? ?-failindex var? str"}} test string-6.2.$noComp {string is, too few args} { list [catch {run {string is alpha}} msg] $msg } {1 {wrong # args: should be "string is class ?-strict? ?-failindex var? str"}} test string-6.3.$noComp {string is, bad args} { list [catch {run {string is alpha -failin str}} msg] $msg } {1 {wrong # args: should be "string is alpha ?-strict? ?-failindex var? str"}} test string-6.4.$noComp {string is, too many args} { list [catch {run {string is alpha -failin var -strict str more}} msg] $msg } {1 {wrong # args: should be "string is class ?-strict? ?-failindex var? str"}} test string-6.5.$noComp {string is, class check} { list [catch {run {string is bogus str}} msg] $msg } {1 {bad class "bogus": must be alnum, alpha, ascii, control, boolean, digit, double, entier, false, graph, integer, list, lower, print, punct, space, true, upper, wideinteger, wordchar, or xdigit}} test string-6.6.$noComp {string is, ambiguous class} { list [catch {run {string is al str}} msg] $msg } {1 {ambiguous class "al": must be alnum, alpha, ascii, control, boolean, digit, double, entier, false, graph, integer, list, lower, print, punct, space, true, upper, wideinteger, wordchar, or xdigit}} test string-6.7.$noComp {string is alpha, all ok} { run {string is alpha -strict -failindex var abc} } 1 test string-6.8.$noComp {string is, error in var} { list [run {string is alpha -failindex var abc5def}] $var } {0 3} test string-6.9.$noComp {string is, var shouldn't get set} { catch {unset var} list [catch {run {string is alpha -failindex var abc; set var}} msg] $msg } {1 {can't read "var": no such variable}} test string-6.10.$noComp {string is, ok on empty} { run {string is alpha {}} } 1 test string-6.11.$noComp {string is, -strict check against empty} { run {string is alpha -strict {}} } 0 test string-6.12.$noComp {string is alnum, true} { run {string is alnum abc123} } 1 test string-6.13.$noComp {string is alnum, false} { list [run {string is alnum -failindex var abc1.23}] $var } {0 4} test string-6.14.$noComp {string is alnum, unicode} "run {string is alnum abc\xfc}" 1 test string-6.15.$noComp {string is alpha, true} { run {string is alpha abc} } 1 test string-6.16.$noComp {string is alpha, false} { list [run {string is alpha -fail var a1bcde}] $var } {0 1} test string-6.17.$noComp {string is alpha, unicode} { run {string is alpha abc\374} } 1 test string-6.18.$noComp {string is ascii, true} { run {string is ascii abc\u007Fend\u0000} } 1 test string-6.19.$noComp {string is ascii, false} { list [run {string is ascii -fail var abc\u0000def\u0080more}] $var } {0 7} test string-6.20.$noComp {string is boolean, true} { run {string is boolean true} } 1 test string-6.21.$noComp {string is boolean, true} { run {string is boolean f} } 1 test string-6.22.$noComp {string is boolean, true based on type} { run {string is bool [run {string compare a a}]} } 1 test string-6.23.$noComp {string is boolean, false} { list [run {string is bool -fail var yada}] $var } {0 0} test string-6.24.$noComp {string is digit, true} { run {string is digit 0123456789} } 1 test string-6.25.$noComp {string is digit, false} { list [run {string is digit -fail var 0123\u00dc567}] $var } {0 4} test string-6.26.$noComp {string is digit, false} { list [run {string is digit -fail var +123567}] $var } {0 0} test string-6.27.$noComp {string is double, true} { run {string is double 1} } 1 test string-6.28.$noComp {string is double, true} { run {string is double [expr double(1)]} } 1 test string-6.29.$noComp {string is double, true} { run {string is double 1.0} } 1 test string-6.30.$noComp {string is double, true} { run {string is double [run {string compare a a}]} } 1 test string-6.31.$noComp {string is double, true} { run {string is double " +1.0e-1 "} } 1 test string-6.32.$noComp {string is double, true} { run {string is double "\n1.0\v"} } 1 test string-6.33.$noComp {string is double, false} { list [run {string is double -fail var 1abc}] $var } {0 1} test string-6.34.$noComp {string is double, false} { list [run {string is double -fail var abc}] $var } {0 0} test string-6.35.$noComp {string is double, false} { list [run {string is double -fail var " 1.0e4e4 "}] $var } {0 8} test string-6.36.$noComp {string is double, false} { list [run {string is double -fail var "\n"}] $var } {0 0} test string-6.37.$noComp {string is double, false on int overflow} -setup { set var priorValue } -body { # Make it the largest int recognizable, with one more digit for overflow # Since bignums arrived in Tcl 8.5, the sense of this test changed. # Now integer values that exceed native limits become bignums, and # bignums can convert to doubles without error. list [run {string is double -fail var [largest_int]0}] $var } -result {1 priorValue} # string-6.38 removed, underflow on input is no longer an error. test string-6.39.$noComp {string is double, false} { # This test is non-portable because IRIX thinks # that .e1 is a valid double - this is really a bug # on IRIX as .e1 should NOT be a valid double # # Portable now. Tcl 8.5 does its own double parsing. list [run {string is double -fail var .e1}] $var } {0 0} test string-6.40.$noComp {string is false, true} { run {string is false false} } 1 test string-6.41.$noComp {string is false, true} { run {string is false FaLsE} } 1 test string-6.42.$noComp {string is false, true} { run {string is false N} } 1 test string-6.43.$noComp {string is false, true} { run {string is false 0} } 1 test string-6.44.$noComp {string is false, true} { run {string is false off} } 1 test string-6.45.$noComp {string is false, false} { list [run {string is false -fail var abc}] $var } {0 0} test string-6.46.$noComp {string is false, false} { catch {unset var} list [run {string is false -fail var Y}] $var } {0 0} test string-6.47.$noComp {string is false, false} { catch {unset var} list [run {string is false -fail var offensive}] $var } {0 0} test string-6.48.$noComp {string is integer, true} { run {string is integer +1234567890} } 1 test string-6.49.$noComp {string is integer, true on type} { run {string is integer [expr int(50.0)]} } 1 test string-6.50.$noComp {string is integer, true} { run {string is integer [list -10]} } 1 test string-6.51.$noComp {string is integer, true as hex} { run {string is integer 0xabcdef} } 1 test string-6.52.$noComp {string is integer, true as octal} { run {string is integer 012345} } 1 test string-6.53.$noComp {string is integer, true with whitespace} { run {string is integer " \n1234\v"} } 1 test string-6.54.$noComp {string is integer, false} { list [run {string is integer -fail var 123abc}] $var } {0 3} test string-6.55.$noComp {string is integer, false on overflow} { list [run {string is integer -fail var +[largest_int]0}] $var } {0 -1} test string-6.56.$noComp {string is integer, false} { list [run {string is integer -fail var [expr double(1)]}] $var } {0 1} test string-6.57.$noComp {string is integer, false} { list [run {string is integer -fail var " "}] $var } {0 0} test string-6.58.$noComp {string is integer, false on bad octal} { list [run {string is integer -fail var 0o36963}] $var } {0 4} test string-6.58.1.$noComp {string is integer, false on bad octal} { list [run {string is integer -fail var 0o36963}] $var } {0 4} test string-6.59.$noComp {string is integer, false on bad hex} { list [run {string is integer -fail var 0X345XYZ}] $var } {0 5} test string-6.60.$noComp {string is lower, true} { run {string is lower abc} } 1 test string-6.61.$noComp {string is lower, unicode true} { run {string is lower abc\u00fcue} } 1 test string-6.62.$noComp {string is lower, false} { list [run {string is lower -fail var aBc}] $var } {0 1} test string-6.63.$noComp {string is lower, false} { list [run {string is lower -fail var abc1}] $var } {0 3} test string-6.64.$noComp {string is lower, unicode false} { list [run {string is lower -fail var ab\u00dcUE}] $var } {0 2} test string-6.65.$noComp {string is space, true} { run {string is space " \t\n\v\f"} } 1 test string-6.66.$noComp {string is space, false} { list [run {string is space -fail var " \t\n\v1\f"}] $var } {0 4} test string-6.67.$noComp {string is true, true} { run {string is true true} } 1 test string-6.68.$noComp {string is true, true} { run {string is true TrU} } 1 test string-6.69.$noComp {string is true, true} { run {string is true ye} } 1 test string-6.70.$noComp {string is true, true} { run {string is true 1} } 1 test string-6.71.$noComp {string is true, true} { run {string is true on} } 1 test string-6.72.$noComp {string is true, false} { list [run {string is true -fail var onto}] $var } {0 0} test string-6.73.$noComp {string is true, false} { catch {unset var} list [run {string is true -fail var 25}] $var } {0 0} test string-6.74.$noComp {string is true, false} { catch {unset var} list [run {string is true -fail var no}] $var } {0 0} test string-6.75.$noComp {string is upper, true} { run {string is upper ABC} } 1 test string-6.76.$noComp {string is upper, unicode true} { run {string is upper ABC\u00dcUE} } 1 test string-6.77.$noComp {string is upper, false} { list [run {string is upper -fail var AbC}] $var } {0 1} test string-6.78.$noComp {string is upper, false} { list [run {string is upper -fail var AB2C}] $var } {0 2} test string-6.79.$noComp {string is upper, unicode false} { list [run {string is upper -fail var ABC\u00fcue}] $var } {0 3} test string-6.80.$noComp {string is wordchar, true} { run {string is wordchar abc_123} } 1 test string-6.81.$noComp {string is wordchar, unicode true} { run {string is wordchar abc\u00fcab\u00dcAB\u5001} } 1 test string-6.82.$noComp {string is wordchar, false} { list [run {string is wordchar -fail var abcd.ef}] $var } {0 4} test string-6.83.$noComp {string is wordchar, unicode false} { list [run {string is wordchar -fail var abc\u0080def}] $var } {0 3} test string-6.84.$noComp {string is control} { ## Control chars are in the ranges ## 00..1F && 7F..9F list [run {string is control -fail var \x00\x01\x10\x1F\x7F\x80\x9F\x60}] $var } {0 7} test string-6.85.$noComp {string is control} { run {string is control \u0100} } 0 test string-6.86.$noComp {string is graph} { ## graph is any print char, except space list [run {string is gra -fail var "0123abc!@#\$\u0100\UE0100\UE01EF "}] $var } {0 14} test string-6.87.$noComp {string is print} { ## basically any printable char list [run {string is print -fail var "0123abc!@#\$\u0100 \UE0100\UE01EF\u0010"}] $var } {0 15} test string-6.88.$noComp {string is punct} { ## any graph char that isn't alnum list [run {string is punct -fail var "_!@#\u00beq0"}] $var } {0 4} test string-6.89.$noComp {string is xdigit} { list [run {string is xdigit -fail var 0123456789\u0061bcdefABCDEFg}] $var } {0 22} test string-6.90.$noComp {string is integer, bad integers} { # SF bug #634856 set result "" set numbers [list 1 +1 ++1 +-1 -+1 -1 --1 "- +1"] foreach num $numbers { lappend result [run {string is int -strict $num}] } return $result } {1 1 0 0 0 1 0 0} test string-6.91.$noComp {string is double, bad doubles} { set result "" set numbers [list 1.0 +1.0 ++1.0 +-1.0 -+1.0 -1.0 --1.0 "- +1.0"] foreach num $numbers { lappend result [run {string is double -strict $num}] } return $result } {1 1 0 0 0 1 0 0} test string-6.92.$noComp {string is integer, 32-bit overflow} { # Bug 718878 set x 0x100000000 list [run {string is integer -failindex var $x}] $var } {0 -1} test string-6.93.$noComp {string is integer, 32-bit overflow} { # Bug 718878 set x 0x100000000 append x "" list [run {string is integer -failindex var $x}] $var } {0 -1} test string-6.94.$noComp {string is integer, 32-bit overflow} { # Bug 718878 set x 0x100000000 list [run {string is integer -failindex var [expr {$x}]}] $var } {0 -1} test string-6.95.$noComp {string is wideinteger, true} { run {string is wideinteger +1234567890} } 1 test string-6.96.$noComp {string is wideinteger, true on type} { run {string is wideinteger [expr wide(50.0)]} } 1 test string-6.97.$noComp {string is wideinteger, true} { run {string is wideinteger [list -10]} } 1 test string-6.98.$noComp {string is wideinteger, true as hex} { run {string is wideinteger 0xabcdef} } 1 test string-6.99.$noComp {string is wideinteger, true as octal} { run {string is wideinteger 0123456} } 1 test string-6.100.$noComp {string is wideinteger, true with whitespace} { run {string is wideinteger " \n1234\v"} } 1 test string-6.101.$noComp {string is wideinteger, false} { list [run {string is wideinteger -fail var 123abc}] $var } {0 3} test string-6.102.$noComp {string is wideinteger, false on overflow} { list [run {string is wideinteger -fail var +[largest_int]0}] $var } {0 -1} test string-6.103.$noComp {string is wideinteger, false} { list [run {string is wideinteger -fail var [expr double(1)]}] $var } {0 1} test string-6.104.$noComp {string is wideinteger, false} { list [run {string is wideinteger -fail var " "}] $var } {0 0} test string-6.105.$noComp {string is wideinteger, false on bad octal} { list [run {string is wideinteger -fail var 0o36963}] $var } {0 4} test string-6.105.1.$noComp {string is wideinteger, false on bad octal} { list [run {string is wideinteger -fail var 0o36963}] $var } {0 4} test string-6.106.$noComp {string is wideinteger, false on bad hex} { list [run {string is wideinteger -fail var 0X345XYZ}] $var } {0 5} test string-6.107.$noComp {string is integer, bad integers} { # SF bug #634856 set result "" set numbers [list 1 +1 ++1 +-1 -+1 -1 --1 "- +1"] foreach num $numbers { lappend result [run {string is wideinteger -strict $num}] } return $result } {1 1 0 0 0 1 0 0} test string-6.108.$noComp {string is double, Bug 1382287} { set x 2turtledoves run {string is double $x} run {string is double $x} } 0 test string-6.109.$noComp {string is double, Bug 1360532} { run {string is double 1\u00a0} } 0 test string-6.110.$noComp {string is entier, true} { run {string is entier +1234567890} } 1 test string-6.111.$noComp {string is entier, true on type} { run {string is entier [expr wide(50.0)]} } 1 test string-6.112.$noComp {string is entier, true} { run {string is entier [list -10]} } 1 test string-6.113.$noComp {string is entier, true as hex} { run {string is entier 0xabcdef} } 1 test string-6.114.$noComp {string is entier, true as octal} { run {string is entier 0123456} } 1 test string-6.115.$noComp {string is entier, true with whitespace} { run {string is entier " \n1234\v"} } 1 test string-6.116.$noComp {string is entier, false} { list [run {string is entier -fail var 123abc}] $var } {0 3} test string-6.117.$noComp {string is entier, false} { list [run {string is entier -fail var 123123123123123123123123123123123123123123123123123123123123123123123123123123123123abc}] $var } {0 84} test string-6.118.$noComp {string is entier, false} { list [run {string is entier -fail var [expr double(1)]}] $var } {0 1} test string-6.119.$noComp {string is entier, false} { list [run {string is entier -fail var " "}] $var } {0 0} test string-6.120.$noComp {string is entier, false on bad octal} { list [run {string is entier -fail var 0o36963}] $var } {0 4} test string-6.121.1.$noComp {string is entier, false on bad octal} { list [run {string is entier -fail var 0o36963}] $var } {0 4} test string-6.122.$noComp {string is entier, false on bad hex} { list [run {string is entier -fail var 0X345XYZ}] $var } {0 5} test string-6.123.$noComp {string is entier, bad integers} { # SF bug #634856 set result "" set numbers [list 1 +1 ++1 +-1 -+1 -1 --1 "- +1"] foreach num $numbers { lappend result [run {string is entier -strict $num}] } return $result } {1 1 0 0 0 1 0 0} test string-6.124.$noComp {string is entier, true} { run {string is entier +1234567890123456789012345678901234567890} } 1 test string-6.125.$noComp {string is entier, true} { run {string is entier [list -10000000000000000000000000000000000000000000000000000000000000000000000000000000000000]} } 1 test string-6.126.$noComp {string is entier, true as hex} { run {string is entier 0xabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef} } 1 test string-6.127.$noComp {string is entier, true as octal} { run {string is entier 0123456112341234561234565623456123456123456123456123456123456123456123456123456123456} } 1 test string-6.128.$noComp {string is entier, true with whitespace} { run {string is entier " \n12340000000000000000000000000000000000000000000000000000000000000000000000000000000000000\v"} } 1 test string-6.129.$noComp {string is entier, false on bad octal} { list [run {string is entier -fail var 0o1234561123412345612345656234561234561234561234561234561234561234561234561234561234536963}] $var } {0 87} test string-6.130.1.$noComp {string is entier, false on bad octal} { list [run {string is entier -fail var 0o1234561123412345612345656234561234561234561234561234561234561234561234561234561234536963}] $var } {0 87} test string-6.131.$noComp {string is entier, false on bad hex} { list [run {string is entier -fail var 0X12345611234123456123456562345612345612345612345612345612345612345612345612345612345345XYZ}] $var } {0 88} catch {rename largest_int {}} test string-7.1.$noComp {string last, too few args} { list [catch {run {string last a}} msg] $msg } {1 {wrong # args: should be "string last needleString haystackString ?lastIndex?"}} test string-7.2.$noComp {string last, bad args} { list [catch {run {string last a b c}} msg] $msg } {1 {bad index "c": must be integer?[+-]integer? or end?[+-]integer?}} test string-7.3.$noComp {string last, too many args} { list [catch {run {string last a b c d}} msg] $msg } {1 {wrong # args: should be "string last needleString haystackString ?lastIndex?"}} test string-7.4.$noComp {string last} { run {string la xxx xxxx123xx345x678} } 1 test string-7.5.$noComp {string last} { run {string last xx xxxx123xx345x678} } 7 test string-7.6.$noComp {string last} { run {string las x xxxx123xx345x678} } 12 test string-7.7.$noComp {string last, unicode} { run {string las x xxxx12\u7266xx345x678} } 12 test string-7.8.$noComp {string last, unicode} { run {string las \u7266 xxxx12\u7266xx345x678} } 6 test string-7.9.$noComp {string last, stop index} { run {string las \u7266 xxxx12\u7266xx345x678} } 6 test string-7.10.$noComp {string last, unicode} { run {string las \u7266 xxxx12\u7266xx345x678} } 6 test string-7.11.$noComp {string last, start index} { run {string last \u7266 abc\u7266x 3} } 3 test string-7.12.$noComp {string last, start index} { run {string last \u7266 abc\u7266x 2} } -1 test string-7.13.$noComp {string last, start index} { ## Constrain to last 'a' should work run {string last ba badbad end-1} } 3 test string-7.14.$noComp {string last, start index} { ## Constrain to last 'b' should skip last 'ba' run {string last ba badbad end-2} } 0 test string-7.15.$noComp {string last, start index} { run {string last \334a \334ad\334ad 0} } -1 test string-7.16.$noComp {string last, start index} { run {string last \334a \334ad\334ad end-1} } 3 test string-8.1.$noComp {string bytelength} { list [catch {run {string bytelength}} msg] $msg } {1 {wrong # args: should be "string bytelength string"}} test string-8.2.$noComp {string bytelength} { list [catch {run {string bytelength a b}} msg] $msg } {1 {wrong # args: should be "string bytelength string"}} test string-8.3.$noComp {string bytelength} { run {string bytelength "\u00c7"} } 2 test string-8.4.$noComp {string bytelength} { run {string b ""} } 0 test string-9.1.$noComp {string length} { list [catch {run {string length}} msg] $msg } {1 {wrong # args: should be "string length string"}} test string-9.2.$noComp {string length} { list [catch {run {string length a b}} msg] $msg } {1 {wrong # args: should be "string length string"}} test string-9.3.$noComp {string length} { run {string length "a little string"} } 15 test string-9.4.$noComp {string length} { run {string le ""} } 0 test string-9.5.$noComp {string length, unicode} { run {string le "abcd\u7266"} } 5 test string-9.6.$noComp {string length, bytearray object} { run {string length [binary format a5 foo]} } 5 test string-9.7.$noComp {string length, bytearray object} { run {string length [binary format I* {0x50515253 0x52}]} } 8 test string-10.1.$noComp {string map, too few args} { list [catch {run {string map}} msg] $msg } {1 {wrong # args: should be "string map ?-nocase? charMap string"}} test string-10.2.$noComp {string map, bad args} { list [catch {run {string map {a b} abba oops}} msg] $msg } {1 {bad option "a b": must be -nocase}} test string-10.3.$noComp {string map, too many args} { list [catch {run {string map -nocase {a b} str1 str2}} msg] $msg } {1 {wrong # args: should be "string map ?-nocase? charMap string"}} test string-10.4.$noComp {string map} { run {string map {a b} abba} } {bbbb} test string-10.5.$noComp {string map} { run {string map {a b} a} } {b} test string-10.6.$noComp {string map -nocase} { run {string map -nocase {a b} Abba} } {bbbb} test string-10.7.$noComp {string map} { run {string map {abc 321 ab * a A} aabcabaababcab} } {A321*A*321*} test string-10.8.$noComp {string map -nocase} { run {string map -nocase {aBc 321 Ab * a A} aabcabaababcab} } {A321*A*321*} test string-10.9.$noComp {string map -nocase} { run {string map -no {abc 321 Ab * a A} aAbCaBaAbAbcAb} } {A321*A*321*} test string-10.10.$noComp {string map} { list [catch {run {string map {a b c} abba}} msg] $msg } {1 {char map list unbalanced}} test string-10.11.$noComp {string map, nulls} { run {string map {\x00 NULL blah \x00nix} {qwerty}} } {qwerty} test string-10.12.$noComp {string map, unicode} { run {string map [list \374 ue UE \334] "a\374ueUE\000EU"} } aueue\334\0EU test string-10.13.$noComp {string map, -nocase unicode} { run {string map -nocase [list \374 ue UE \334] "a\374ueUE\000EU"} } aue\334\334\0EU test string-10.14.$noComp {string map, -nocase null arguments} { run {string map -nocase {{} abc} foo} } foo test string-10.15.$noComp {string map, one pair case} { run {string map -nocase {abc 32} aAbCaBaAbAbcAb} } {a32aBaAb32Ab} test string-10.16.$noComp {string map, one pair case} { run {string map -nocase {ab 4321} aAbCaBaAbAbcAb} } {a4321C4321a43214321c4321} test string-10.17.$noComp {string map, one pair case} { run {string map {Ab 4321} aAbCaBaAbAbcAb} } {a4321CaBa43214321c4321} test string-10.18.$noComp {string map, empty argument} { run {string map -nocase {{} abc} foo} } foo test string-10.19.$noComp {string map, empty arguments} { run {string map -nocase {{} abc f bar {} def} foo} } baroo test string-10.20.$noComp {string map, dictionaries don't alter map ordering} { set map {aa X a Y} list [run {string map [dict create aa X a Y] aaa}] [run {string map $map aaa}] [dict size $map] [run {string map $map aaa}] } {XY XY 2 XY} test string-10.20.1.$noComp {string map, dictionaries don't alter map ordering} { set map {a X b Y a Z} list [run {string map [dict create a X b Y a Z] aaa}] [run {string map $map aaa}] [dict size $map] [run {string map $map aaa}] } {ZZZ XXX 2 XXX} test string-10.21.$noComp {string map, ABR checks} { run {string map {longstring foob} long} } long test string-10.22.$noComp {string map, ABR checks} { run {string map {long foob} long} } foob test string-10.23.$noComp {string map, ABR checks} { run {string map {lon foob} long} } foobg test string-10.24.$noComp {string map, ABR checks} { run {string map {lon foob} longlo} } foobglo test string-10.25.$noComp {string map, ABR checks} { run {string map {lon foob} longlon} } foobgfoob test string-10.26.$noComp {string map, ABR checks} { run {string map {longstring foob longstring bar} long} } long test string-10.27.$noComp {string map, ABR checks} { run {string map {long foob longstring bar} long} } foob test string-10.28.$noComp {string map, ABR checks} { run {string map {lon foob longstring bar} long} } foobg test string-10.29.$noComp {string map, ABR checks} { run {string map {lon foob longstring bar} longlo} } foobglo test string-10.30.$noComp {string map, ABR checks} { run {string map {lon foob longstring bar} longlon} } foobgfoob test string-10.31.$noComp {string map, nasty sharing crash from [Bug 1018562]} { set a {a b} run {string map $a $a} } {b b} test string-11.1.$noComp {string match, too few args} { list [catch {run {string match a}} msg] $msg } {1 {wrong # args: should be "string match ?-nocase? pattern string"}} test string-11.2.$noComp {string match, too many args} { list [catch {run {string match a b c d}} msg] $msg } {1 {wrong # args: should be "string match ?-nocase? pattern string"}} test string-11.3.$noComp {string match} { run {string match abc abc} } 1 test string-11.4.$noComp {string match} { run {string mat abc abd} } 0 test string-11.5.$noComp {string match} { run {string match ab*c abc} } 1 test string-11.6.$noComp {string match} { run {string match ab**c abc} } 1 test string-11.7.$noComp {string match} { run {string match ab* abcdef} } 1 test string-11.8.$noComp {string match} { run {string match *c abc} } 1 test string-11.9.$noComp {string match} { run {string match *3*6*9 0123456789} } 1 test string-11.9.1.$noComp {string match} { run {string match *3*6*89 0123456789} } 1 test string-11.9.2.$noComp {string match} { run {string match *3*456*89 0123456789} } 1 test string-11.9.3.$noComp {string match} { run {string match *3*6* 0123456789} } 1 test string-11.9.4.$noComp {string match} { run {string match *3*56* 0123456789} } 1 test string-11.9.5.$noComp {string match} { run {string match *3*456*** 0123456789} } 1 test string-11.9.6.$noComp {string match} { run {string match **3*456** 0123456789} } 1 test string-11.9.7.$noComp {string match} { run {string match *3***456* 0123456789} } 1 test string-11.9.8.$noComp {string match} { run {string match *3***\[456]* 0123456789} } 1 test string-11.9.9.$noComp {string match} { run {string match *3***\[4-6]* 0123456789} } 1 test string-11.9.10.$noComp {string match} { run {string match *3***\[4-6] 0123456789} } 0 test string-11.9.11.$noComp {string match} { run {string match *3***\[4-6] 0123456} } 1 test string-11.10.$noComp {string match} { run {string match *3*6*9 01234567890} } 0 test string-11.10.1.$noComp {string match} { run {string match *3*6*89 01234567890} } 0 test string-11.10.2.$noComp {string match} { run {string match *3*456*89 01234567890} } 0 test string-11.10.3.$noComp {string match} { run {string match **3*456*89 01234567890} } 0 test string-11.10.4.$noComp {string match} { run {string match *3*456***89 01234567890} } 0 test string-11.11.$noComp {string match} { run {string match a?c abc} } 1 test string-11.12.$noComp {string match} { run {string match a??c abc} } 0 test string-11.13.$noComp {string match} { run {string match ?1??4???8? 0123456789} } 1 test string-11.14.$noComp {string match} { run {string match {[abc]bc} abc} } 1 test string-11.15.$noComp {string match} { run {string match {a[abc]c} abc} } 1 test string-11.16.$noComp {string match} { run {string match {a[xyz]c} abc} } 0 test string-11.17.$noComp {string match} { run {string match {12[2-7]45} 12345} } 1 test string-11.18.$noComp {string match} { run {string match {12[ab2-4cd]45} 12345} } 1 test string-11.19.$noComp {string match} { run {string match {12[ab2-4cd]45} 12b45} } 1 test string-11.20.$noComp {string match} { run {string match {12[ab2-4cd]45} 12d45} } 1 test string-11.21.$noComp {string match} { run {string match {12[ab2-4cd]45} 12145} } 0 test string-11.22.$noComp {string match} { run {string match {12[ab2-4cd]45} 12545} } 0 test string-11.23.$noComp {string match} { run {string match {a\*b} a*b} } 1 test string-11.24.$noComp {string match} { run {string match {a\*b} ab} } 0 test string-11.25.$noComp {string match} { run {string match {a\*\?\[\]\\\x} "a*?\[\]\\x"} } 1 test string-11.26.$noComp {string match} { run {string match ** ""} } 1 test string-11.27.$noComp {string match} { run {string match *. ""} } 0 test string-11.28.$noComp {string match} { run {string match "" ""} } 1 test string-11.29.$noComp {string match} { run {string match \[a a} } 1 test string-11.30.$noComp {string match, bad args} { list [catch {run {string match - b c}} msg] $msg } {1 {bad option "-": must be -nocase}} test string-11.31.$noComp {string match case} { run {string match a A} } 0 test string-11.32.$noComp {string match nocase} { run {string match -n a A} } 1 test string-11.33.$noComp {string match nocase} { run {string match -nocase a\334 A\374} } 1 test string-11.34.$noComp {string match nocase} { run {string match -nocase a*f ABCDEf} } 1 test string-11.35.$noComp {string match case, false hope} { # This is true because '_' lies between the A-Z and a-z ranges run {string match {[A-z]} _} } 1 test string-11.36.$noComp {string match nocase range} { # This is false because although '_' lies between the A-Z and a-z ranges, # we lower case the end points before checking the ranges. run {string match -nocase {[A-z]} _} } 0 test string-11.37.$noComp {string match nocase} { run {string match -nocase {[A-fh-Z]} g} } 0 test string-11.38.$noComp {string match case, reverse range} { run {string match {[A-fh-Z]} g} } 1 test string-11.39.$noComp {string match, *\ case} { run {string match {*\abc} abc} } 1 test string-11.39.1.$noComp {string match, *\ case} { run {string match {*ab\c} abc} } 1 test string-11.39.2.$noComp {string match, *\ case} { run {string match {*ab\*} ab*} } 1 test string-11.39.3.$noComp {string match, *\ case} { run {string match {*ab\*} abc} } 0 test string-11.39.4.$noComp {string match, *\ case} { run {string match {*ab\\*} {ab\c}} } 1 test string-11.39.5.$noComp {string match, *\ case} { run {string match {*ab\\*} {ab\*}} } 1 test string-11.40.$noComp {string match, *special case} { run {string match {*[ab]} abc} } 0 test string-11.41.$noComp {string match, *special case} { run {string match {*[ab]*} abc} } 1 test string-11.42.$noComp {string match, *special case} { run {string match "*\\" "\\"} } 0 test string-11.43.$noComp {string match, *special case} { run {string match "*\\\\" "\\"} } 1 test string-11.44.$noComp {string match, *special case} { run {string match "*???" "12345"} } 1 test string-11.45.$noComp {string match, *special case} { run {string match "*???" "12"} } 0 test string-11.46.$noComp {string match, *special case} { run {string match "*\\*" "abc*"} } 1 test string-11.47.$noComp {string match, *special case} { run {string match "*\\*" "*"} } 1 test string-11.48.$noComp {string match, *special case} { run {string match "*\\*" "*abc"} } 0 test string-11.49.$noComp {string match, *special case} { run {string match "?\\*" "a*"} } 1 test string-11.50.$noComp {string match, *special case} { run {string match "\\" "\\"} } 0 test string-11.51.$noComp {string match; *, -nocase and UTF-8} { run {string match -nocase [binary format I 717316707] \ [binary format I 2028036707]} } 1 test string-11.52.$noComp {string match, null char in string} { set out "" set ptn "*abc*" foreach elem [list "\u0000@abc" "@abc" "\u0000@abc\u0000" "blahabcblah"] { lappend out [run {string match $ptn $elem}] } set out } {1 1 1 1} test string-11.53.$noComp {string match, null char in pattern} { set out "" foreach {ptn elem} [list \ "*\u0000abc\u0000" "\u0000abc\u0000" \ "*\u0000abc\u0000" "\u0000abc\u0000ef" \ "*\u0000abc\u0000*" "\u0000abc\u0000ef" \ "*\u0000abc\u0000" "@\u0000abc\u0000ef" \ "*\u0000abc\u0000*" "@\u0000abc\u0000ef" \ ] { lappend out [run {string match $ptn $elem}] } set out } {1 0 1 0 1} test string-11.54.$noComp {string match, failure} { set longString "" for {set i 0} {$i < 10} {incr i} { append longString "abcdefghijklmnopqrstuvwxy\u0000z01234567890123" } run {string first $longString 123} list [run {string match *cba* $longString}] \ [run {string match *a*l*\u0000* $longString}] \ [run {string match *a*l*\u0000*123 $longString}] \ [run {string match *a*l*\u0000*123* $longString}] \ [run {string match *a*l*\u0000*cba* $longString}] \ [run {string match *===* $longString}] } {0 1 1 1 0 0} test string-11.55.$noComp {string match, invalid binary optimization} { [format string] match \u0141 [binary format c 65] } 0 test stringComp-12.1.0.$noComp {Bug 3588366: end-offsets before start} { apply {s { string range $s 0 end-5 }} 12345 } {} test string-12.1.$noComp {string range} { list [catch {run {string range}} msg] $msg } {1 {wrong # args: should be "string range string first last"}} test string-12.2.$noComp {string range} { list [catch {run {string range a 1}} msg] $msg } {1 {wrong # args: should be "string range string first last"}} test string-12.3.$noComp {string range} { list [catch {run {string range a 1 2 3}} msg] $msg } {1 {wrong # args: should be "string range string first last"}} test string-12.4.$noComp {string range} { run {string range abcdefghijklmnop 2 14} } {cdefghijklmno} test string-12.5.$noComp {string range, last > length} { run {string range abcdefghijklmnop 7 1000} } {hijklmnop} test string-12.6.$noComp {string range} { run {string range abcdefghijklmnop 10 end} } {klmnop} test string-12.7.$noComp {string range, last < first} { run {string range abcdefghijklmnop 10 9} } {} test string-12.8.$noComp {string range, first < 0} { run {string range abcdefghijklmnop -3 2} } {abc} test string-12.9.$noComp {string range} { run {string range abcdefghijklmnop -3 -2} } {} test string-12.10.$noComp {string range} { run {string range abcdefghijklmnop 1000 1010} } {} test string-12.11.$noComp {string range} { run {string range abcdefghijklmnop -100 end} } {abcdefghijklmnop} test string-12.12.$noComp {string range} { list [catch {run {string range abc abc 1}} msg] $msg } {1 {bad index "abc": must be integer?[+-]integer? or end?[+-]integer?}} test string-12.13.$noComp {string range} { list [catch {run {string range abc 1 eof}} msg] $msg } {1 {bad index "eof": must be integer?[+-]integer? or end?[+-]integer?}} test string-12.14.$noComp {string range} { run {string range abcdefghijklmnop end-1 end} } {op} test string-12.15.$noComp {string range} { run {string range abcdefghijklmnop end 1000} } {p} test string-12.16.$noComp {string range} { run {string range abcdefghijklmnop end end-1} } {} test string-12.17.$noComp {string range, unicode} { run {string range ab\u7266cdefghijklmnop 5 5} } e test string-12.18.$noComp {string range, unicode} { run {string range ab\u7266cdefghijklmnop 2 3} } \u7266c test string-12.19.$noComp {string range, bytearray object} { set b [binary format I* {0x50515253 0x52}] set r1 [run {string range $b 1 end-1}] set r2 [run {string range $b 1 6}] run {string equal $r1 $r2} } 1 test string-12.20.$noComp {string range, out of bounds indices} { run {string range \u00ff 0 1} } \u00ff # Bug 1410553 test string-12.21.$noComp {string range, regenerates correct reps, bug 1410553} { set bytes "\x00 \x03 \x41" set rxBuffer {} foreach ch $bytes { append rxBuffer $ch if {$ch eq "\x03"} { run {string length $rxBuffer} } } set rxCRC [run {string range $rxBuffer end-1 end}] binary scan [join $bytes {}] "H*" input_hex binary scan $rxBuffer "H*" rxBuffer_hex binary scan $rxCRC "H*" rxCRC_hex list $input_hex $rxBuffer_hex $rxCRC_hex } {000341 000341 0341} test string-12.22.$noComp {string range, shimmering binary/index} { set s 0000000001 binary scan $s a* x run {string range $s $s end} } 000000001 test string-12.23.$noComp {string range, surrogates, bug [11ae2be95dac9417]} fullutf { run {list [string range a\U100000b 1 1] [string range a\U100000b 2 2] [string range a\U100000b 3 3]} } [list \U100000 {} b] test string-13.1.$noComp {string repeat} { list [catch {run {string repeat}} msg] $msg } {1 {wrong # args: should be "string repeat string count"}} test string-13.2.$noComp {string repeat} { list [catch {run {string repeat abc 10 oops}} msg] $msg } {1 {wrong # args: should be "string repeat string count"}} test string-13.3.$noComp {string repeat} { run {string repeat {} 100} } {} test string-13.4.$noComp {string repeat} { run {string repeat { } 5} } { } test string-13.5.$noComp {string repeat} { run {string repeat abc 3} } {abcabcabc} test string-13.6.$noComp {string repeat} { run {string repeat abc -1} } {} test string-13.7.$noComp {string repeat} { list [catch {run {string repeat abc end}} msg] $msg } {1 {expected integer but got "end"}} test string-13.8.$noComp {string repeat} { run {string repeat {} -1000} } {} test string-13.9.$noComp {string repeat} { run {string repeat {} 0} } {} test string-13.10.$noComp {string repeat} { run {string repeat def 0} } {} test string-13.11.$noComp {string repeat} { run {string repeat def 1} } def test string-13.12.$noComp {string repeat} { run {string repeat ab\u7266cd 3} } ab\u7266cdab\u7266cdab\u7266cd test string-13.13.$noComp {string repeat} { run {string repeat \x00 3} } \x00\x00\x00 test string-13.14.$noComp {string repeat} { # The string range will ensure us that string repeat gets a unicode string run {string repeat [run {string range ab\u7266cd 2 3}] 3} } \u7266c\u7266c\u7266c test string-14.1.$noComp {string replace} { list [catch {run {string replace}} msg] $msg } {1 {wrong # args: should be "string replace string first last ?string?"}} test string-14.2.$noComp {string replace} { list [catch {run {string replace a 1}} msg] $msg } {1 {wrong # args: should be "string replace string first last ?string?"}} test string-14.3.$noComp {string replace} { list [catch {run {string replace a 1 2 3 4}} msg] $msg } {1 {wrong # args: should be "string replace string first last ?string?"}} test string-14.4.$noComp {string replace} { } {} test string-14.5.$noComp {string replace} { run {string replace abcdefghijklmnop 2 14} } {abp} test string-14.6.$noComp {string replace} { run {string replace abcdefghijklmnop 7 1000} } {abcdefg} test string-14.7.$noComp {string replace} { run {string replace abcdefghijklmnop 10 end} } {abcdefghij} test string-14.8.$noComp {string replace} { run {string replace abcdefghijklmnop 10 9} } {abcdefghijklmnop} test string-14.9.$noComp {string replace} { run {string replace abcdefghijklmnop -3 2} } {defghijklmnop} test string-14.10.$noComp {string replace} { run {string replace abcdefghijklmnop -3 -2} } {abcdefghijklmnop} test string-14.11.$noComp {string replace} { run {string replace abcdefghijklmnop 1000 1010} } {abcdefghijklmnop} test string-14.12.$noComp {string replace} { run {string replace abcdefghijklmnop -100 end} } {} test string-14.13.$noComp {string replace} { list [catch {run {string replace abc abc 1}} msg] $msg } {1 {bad index "abc": must be integer?[+-]integer? or end?[+-]integer?}} test string-14.14.$noComp {string replace} { list [catch {run {string replace abc 1 eof}} msg] $msg } {1 {bad index "eof": must be integer?[+-]integer? or end?[+-]integer?}} test string-14.15.$noComp {string replace} { run {string replace abcdefghijklmnop end-10 end-2 NEW} } {abcdeNEWop} test string-14.16.$noComp {string replace} { run {string replace abcdefghijklmnop 0 end foo} } {foo} test string-14.17.$noComp {string replace} { run {string replace abcdefghijklmnop end end-1} } {abcdefghijklmnop} test string-14.18.$noComp {string replace} { run {string replace abcdefghijklmnop 10 9 XXX} } {abcdefghijklmnop} test string-14.19.$noComp {string replace} { run {string replace {} -1 0 A} } A test string-14.20.$noComp {string replace} { run {string replace [makeByteArray abcdefghijklmnop] end-10 end-2\ [makeByteArray NEW]} } {abcdeNEWop} test stringComp-14.21.$noComp {Bug 82e7f67325} { apply {x { set a [join $x {}] lappend b [string length [string replace ___! 0 2 $a]] lappend b [string length [string replace ___! 0 2 $a[unset a]]] }} {a b} } {3 3} test stringComp-14.22.$noComp {Bug 82e7f67325} memory { # As in stringComp-14.1, but make sure we don't retain too many refs leaktest { apply {x { set a [join $x {}] lappend b [string length [string replace ___! 0 2 $a]] lappend b [string length [string replace ___! 0 2 $a[unset a]]] }} {a b} } } {0} test stringComp-14.23.$noComp {Bug 0dca3bfa8f} { apply {arg { set argCopy $arg set arg [string replace $arg 1 2 aa] # Crashes in comparison before fix expr {$arg ne $argCopy} }} abcde } 1 test stringComp-14.24.$noComp {Bug 1af8de570511} { apply {{x y} { # Generate an unshared string value set val "" for { set i 0 } { $i < $x } { incr i } { set val [format "0%s" $val] } string replace $val[unset val] 1 1 $y }} 4 x } 0x00 test stringComp-14.25.$noComp {} { string length [string replace [string repeat a\u00fe 2] 3 end {}] } 3 test string-15.1.$noComp {string tolower too few args} { list [catch {run {string tolower}} msg] $msg } {1 {wrong # args: should be "string tolower string ?first? ?last?"}} test string-15.2.$noComp {string tolower bad args} { list [catch {run {string tolower a b}} msg] $msg } {1 {bad index "b": must be integer?[+-]integer? or end?[+-]integer?}} test string-15.3.$noComp {string tolower too many args} { list [catch {run {string tolower ABC 1 end oops}} msg] $msg } {1 {wrong # args: should be "string tolower string ?first? ?last?"}} test string-15.4.$noComp {string tolower} { run {string tolower ABCDeF} } {abcdef} test string-15.5.$noComp {string tolower} { run {string tolower "ABC XyZ"} } {abc xyz} test string-15.6.$noComp {string tolower} { run {string tolower {123#$&*()}} } {123#$&*()} test string-15.7.$noComp {string tolower} { run {string tolower ABC 1} } AbC test string-15.8.$noComp {string tolower} { run {string tolower ABC 1 end} } Abc test string-15.9.$noComp {string tolower} { run {string tolower ABC 0 end-1} } abC test string-15.10.$noComp {string tolower, unicode} { run {string tolower ABCabc\xc7\xe7} } "abcabc\xe7\xe7" test string-15.11.$noComp {string tolower, compiled} { lindex [run {string tolower [list A B [list C]]}] 1 } b test string-16.1.$noComp {string toupper} { list [catch {run {string toupper}} msg] $msg } {1 {wrong # args: should be "string toupper string ?first? ?last?"}} test string-16.2.$noComp {string toupper} { list [catch {run {string toupper a b}} msg] $msg } {1 {bad index "b": must be integer?[+-]integer? or end?[+-]integer?}} test string-16.3.$noComp {string toupper} { list [catch {run {string toupper a 1 end oops}} msg] $msg } {1 {wrong # args: should be "string toupper string ?first? ?last?"}} test string-16.4.$noComp {string toupper} { run {string toupper abCDEf} } {ABCDEF} test string-16.5.$noComp {string toupper} { run {string toupper "abc xYz"} } {ABC XYZ} test string-16.6.$noComp {string toupper} { run {string toupper {123#$&*()}} } {123#$&*()} test string-16.7.$noComp {string toupper} { run {string toupper abc 1} } aBc test string-16.8.$noComp {string toupper} { run {string toupper abc 1 end} } aBC test string-16.9.$noComp {string toupper} { run {string toupper abc 0 end-1} } ABc test string-16.10.$noComp {string toupper, unicode} { run {string toupper ABCabc\xc7\xe7} } "ABCABC\xc7\xc7" test string-16.11.$noComp {string toupper, compiled} { lindex [run {string toupper [list a b [list c]]}] 1 } B test string-17.1.$noComp {string totitle} { list [catch {run {string totitle}} msg] $msg } {1 {wrong # args: should be "string totitle string ?first? ?last?"}} test string-17.2.$noComp {string totitle} { list [catch {run {string totitle a b}} msg] $msg } {1 {bad index "b": must be integer?[+-]integer? or end?[+-]integer?}} test string-17.3.$noComp {string totitle} { run {string totitle abCDEf} } {Abcdef} test string-17.4.$noComp {string totitle} { run {string totitle "abc xYz"} } {Abc xyz} test string-17.5.$noComp {string totitle} { run {string totitle {123#$&*()}} } {123#$&*()} test string-17.6.$noComp {string totitle, unicode} { run {string totitle ABCabc\xc7\xe7} } "Abcabc\xe7\xe7" test string-17.7.$noComp {string totitle, unicode} { run {string totitle \u01f3BCabc\xc7\xe7} } "\u01f2bcabc\xe7\xe7" test string-17.8.$noComp {string totitle, compiled} { lindex [run {string totitle [list aa bb [list cc]]}] 0 } Aa test string-18.1.$noComp {string trim} { list [catch {run {string trim}} msg] $msg } {1 {wrong # args: should be "string trim string ?chars?"}} test string-18.2.$noComp {string trim} { list [catch {run {string trim a b c}} msg] $msg } {1 {wrong # args: should be "string trim string ?chars?"}} test string-18.3.$noComp {string trim} { run {string trim " XYZ "} } {XYZ} test string-18.4.$noComp {string trim} { run {string trim "\t\nXYZ\t\n\r\n"} } {XYZ} test string-18.5.$noComp {string trim} { run {string trim " A XYZ A "} } {A XYZ A} test string-18.6.$noComp {string trim} { run {string trim "XXYYZZABC XXYYZZ" ZYX} } {ABC } test string-18.7.$noComp {string trim} { run {string trim " \t\r "} } {} test string-18.8.$noComp {string trim} { run {string trim {abcdefg} {}} } {abcdefg} test string-18.9.$noComp {string trim} { run {string trim {}} } {} test string-18.10.$noComp {string trim} { run {string trim ABC DEF} } {ABC} test string-18.11.$noComp {string trim, unicode} { run {string trim "\xe7\xe8 AB\xe7C \xe8\xe7" \xe7\xe8} } " AB\xe7C " test string-18.12.$noComp {string trim, unicode default} { run {string trim \ufeff\x00\u0085\u00a0\u1680\u180eABC\u1361\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u202f\u205f\u3000} } ABC\u1361 test string-19.1.$noComp {string trimleft} { list [catch {run {string trimleft}} msg] $msg } {1 {wrong # args: should be "string trimleft string ?chars?"}} test string-19.2.$noComp {string trimleft} { run {string trimleft " XYZ "} } {XYZ } test string-19.3.$noComp {string trimleft, unicode default} { run {string trimleft \ufeff\u0085\u00a0\x00\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u202f\u205f\u3000\u1361ABC} } \u1361ABC test string-20.1.$noComp {string trimright errors} { list [catch {run {string trimright}} msg] $msg } {1 {wrong # args: should be "string trimright string ?chars?"}} test string-20.2.$noComp {string trimright errors} { list [catch {run {string trimg a}} msg] $msg } {1 {unknown or ambiguous subcommand "trimg": must be bytelength, cat, compare, equal, first, index, is, last, length, map, match, range, repeat, replace, reverse, tolower, totitle, toupper, trim, trimleft, trimright, wordend, or wordstart}} test string-20.3.$noComp {string trimright} { run {string trimright " XYZ "} } { XYZ} test string-20.4.$noComp {string trimright} { run {string trimright " "} } {} test string-20.5.$noComp {string trimright} { run {string trimright ""} } {} test string-20.6.$noComp {string trimright, unicode default} { run {string trimright ABC\u1361\u0085\x00\u00a0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u202f\u205f\u3000} } ABC\u1361 test string-21.1.$noComp {string wordend} { list [catch {run {string wordend a}} msg] $msg } {1 {wrong # args: should be "string wordend string index"}} test string-21.2.$noComp {string wordend} { list [catch {run {string wordend a b c}} msg] $msg } {1 {wrong # args: should be "string wordend string index"}} test string-21.3.$noComp {string wordend} { list [catch {run {string wordend a gorp}} msg] $msg } {1 {bad index "gorp": must be integer?[+-]integer? or end?[+-]integer?}} test string-21.4.$noComp {string wordend} { run {string wordend abc. -1} } 3 test string-21.5.$noComp {string wordend} { run {string wordend abc. 100} } 4 test string-21.6.$noComp {string wordend} { run {string wordend "word_one two three" 2} } 8 test string-21.7.$noComp {string wordend} { run {string wordend "one .&# three" 5} } 6 test string-21.8.$noComp {string wordend} { run {string worde "x.y" 0} } 1 test string-21.9.$noComp {string wordend} { run {string worde "x.y" end-1} } 2 test string-21.10.$noComp {string wordend, unicode} { run {string wordend "xyz\u00c7de fg" 0} } 6 test string-21.11.$noComp {string wordend, unicode} { run {string wordend "xyz\uc700de fg" 0} } 6 test string-21.12.$noComp {string wordend, unicode} { run {string wordend "xyz\u203fde fg" 0} } 6 test string-21.13.$noComp {string wordend, unicode} { run {string wordend "xyz\u2045de fg" 0} } 3 test string-21.14.$noComp {string wordend, unicode} { run {string wordend "\uc700\uc700 abc" 8} } 6 test string-22.1.$noComp {string wordstart} { list [catch {run {string word a}} msg] $msg } {1 {unknown or ambiguous subcommand "word": must be bytelength, cat, compare, equal, first, index, is, last, length, map, match, range, repeat, replace, reverse, tolower, totitle, toupper, trim, trimleft, trimright, wordend, or wordstart}} test string-22.2.$noComp {string wordstart} { list [catch {run {string wordstart a}} msg] $msg } {1 {wrong # args: should be "string wordstart string index"}} test string-22.3.$noComp {string wordstart} { list [catch {run {string wordstart a b c}} msg] $msg } {1 {wrong # args: should be "string wordstart string index"}} test string-22.4.$noComp {string wordstart} { list [catch {run {string wordstart a gorp}} msg] $msg } {1 {bad index "gorp": must be integer?[+-]integer? or end?[+-]integer?}} test string-22.5.$noComp {string wordstart} { run {string wordstart "one two three_words" 400} } 8 test string-22.6.$noComp {string wordstart} { run {string wordstart "one two three_words" 2} } 0 test string-22.7.$noComp {string wordstart} { run {string wordstart "one two three_words" -2} } 0 test string-22.8.$noComp {string wordstart} { run {string wordstart "one .*&^ three" 6} } 6 test string-22.9.$noComp {string wordstart} { run {string wordstart "one two three" 4} } 4 test string-22.10.$noComp {string wordstart} { run {string wordstart "one two three" end-5} } 7 test string-22.11.$noComp {string wordstart, unicode} { run {string wordstart "one tw\u00c7o three" 7} } 4 test string-22.12.$noComp {string wordstart, unicode} { run {string wordstart "ab\uc700\uc700 cdef ghi" 12} } 10 test string-22.13.$noComp {string wordstart, unicode} { run {string wordstart "\uc700\uc700 abc" 8} } 3 test string-23.0.$noComp {string is boolean, Bug 1187123} testindexobj { set x 5 catch {testindexobj $x foo bar soom} run {string is boolean $x} } 0 test string-23.1.$noComp {string is command with empty string} { set s "" list \ [run {string is alnum $s}] \ [run {string is alpha $s}] \ [run {string is ascii $s}] \ [run {string is control $s}] \ [run {string is boolean $s}] \ [run {string is digit $s}] \ [run {string is double $s}] \ [run {string is false $s}] \ [run {string is graph $s}] \ [run {string is integer $s}] \ [run {string is lower $s}] \ [run {string is print $s}] \ [run {string is punct $s}] \ [run {string is space $s}] \ [run {string is true $s}] \ [run {string is upper $s}] \ [run {string is wordchar $s}] \ [run {string is xdigit $s}] \ } {1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1} test string-23.2.$noComp {string is command with empty string} { set s "" list \ [run {string is alnum -strict $s}] \ [run {string is alpha -strict $s}] \ [run {string is ascii -strict $s}] \ [run {string is control -strict $s}] \ [run {string is boolean -strict $s}] \ [run {string is digit -strict $s}] \ [run {string is double -strict $s}] \ [run {string is false -strict $s}] \ [run {string is graph -strict $s}] \ [run {string is integer -strict $s}] \ [run {string is lower -strict $s}] \ [run {string is print -strict $s}] \ [run {string is punct -strict $s}] \ [run {string is space -strict $s}] \ [run {string is true -strict $s}] \ [run {string is upper -strict $s}] \ [run {string is wordchar -strict $s}] \ [run {string is xdigit -strict $s}] \ } {0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0} test string-24.1.$noComp {string reverse command} -body { run {string reverse} } -returnCodes error -result "wrong # args: should be \"string reverse string\"" test string-24.2.$noComp {string reverse command} -body { run {string reverse a b} } -returnCodes error -result "wrong # args: should be \"string reverse string\"" test string-24.3.$noComp {string reverse command - shared string} { set x abcde run {string reverse $x} } edcba test string-24.4.$noComp {string reverse command - unshared string} { set x abc set y de run {string reverse $x$y} } edcba test string-24.5.$noComp {string reverse command - shared unicode string} { set x abcde\ud0ad run {string reverse $x} } \ud0adedcba test string-24.6.$noComp {string reverse command - unshared string} { set x abc set y de\ud0ad run {string reverse $x$y} } \ud0adedcba test string-24.7.$noComp {string reverse command - simple case} { run {string reverse a} } a test string-24.8.$noComp {string reverse command - simple case} { run {string reverse \ud0ad} } \ud0ad test string-24.9.$noComp {string reverse command - simple case} { run {string reverse {}} } {} test string-24.10.$noComp {string reverse command - corner case} { set x \ubeef\ud0ad run {string reverse $x} } \ud0ad\ubeef test string-24.11.$noComp {string reverse command - corner case} { set x \ubeef set y \ud0ad run {string reverse $x$y} } \ud0ad\ubeef test string-24.12.$noComp {string reverse command - corner case} { set x \ubeef set y \ud0ad run {string is ascii [run {string reverse $x$y}]} } 0 test string-24.13.$noComp {string reverse command - pure Unicode string} { run {string reverse [run {string range \ubeef\ud0ad\ubeef\ud0ad\ubeef\ud0ad 1 5}]} } \ud0ad\ubeef\ud0ad\ubeef\ud0ad test string-24.14.$noComp {string reverse command - pure bytearray} { binary scan [run {string reverse [binary format H* 010203]}] H* x set x } 030201 test string-24.15.$noComp {string reverse command - pure bytearray} { binary scan [run {tcl::string::reverse [binary format H* 010203]}] H* x set x } 030201 test string-25.1.$noComp {string is list} { run {string is list {a b c}} } 1 test string-25.2.$noComp {string is list} { run {string is list "a \{b c"} } 0 test string-25.3.$noComp {string is list} { run {string is list {a {b c}d e}} } 0 test string-25.4.$noComp {string is list} { run {string is list {}} } 1 test string-25.5.$noComp {string is list} { run {string is list -strict {a b c}} } 1 test string-25.6.$noComp {string is list} { run {string is list -strict "a \{b c"} } 0 test string-25.7.$noComp {string is list} { run {string is list -strict {a {b c}d e}} } 0 test string-25.8.$noComp {string is list} { run {string is list -strict {}} } 1 test string-25.9.$noComp {string is list} { set x {} list [run {string is list -failindex x {a b c}}] $x } {1 {}} test string-25.10.$noComp {string is list} { set x {} list [run {string is list -failindex x "a \{b c"}] $x } {0 2} test string-25.11.$noComp {string is list} { set x {} list [run {string is list -failindex x {a b {b c}d e}}] $x } {0 4} test string-25.12.$noComp {string is list} { set x {} list [run {string is list -failindex x {}}] $x } {1 {}} test string-25.13.$noComp {string is list} { set x {} list [run {string is list -failindex x { {b c}d e}}] $x } {0 2} test string-25.14.$noComp {string is list} { set x {} list [run {string is list -failindex x "\uabcd {b c}d e"}] $x } {0 2} test string-26.1.$noComp {tcl::prefix, too few args} -body { tcl::prefix match a } -returnCodes 1 -result {wrong # args: should be "tcl::prefix match ?options? table string"} test string-26.2.$noComp {tcl::prefix, bad args} -body { tcl::prefix match a b c } -returnCodes 1 -result {bad option "a": must be -error, -exact, or -message} test string-26.2.1.$noComp {tcl::prefix, empty table} -body { tcl::prefix match {} foo } -returnCodes 1 -result {bad option "foo": no valid options} test string-26.3.$noComp {tcl::prefix, bad args} -body { tcl::prefix match -error "{}x" -exact str1 str2 } -returnCodes 1 -result {list element in braces followed by "x" instead of space} test string-26.3.1.$noComp {tcl::prefix, bad args} -body { tcl::prefix match -error "x" -exact str1 str2 } -returnCodes 1 -result {error options must have an even number of elements} test string-26.3.2.$noComp {tcl::prefix, bad args} -body { tcl::prefix match -error str1 str2 } -returnCodes 1 -result {missing value for -error} test string-26.4.$noComp {tcl::prefix, bad args} -body { tcl::prefix match -message str1 str2 } -returnCodes 1 -result {missing value for -message} test string-26.5.$noComp {tcl::prefix} { tcl::prefix match {apa bepa cepa depa} cepa } cepa test string-26.6.$noComp {tcl::prefix} { tcl::prefix match {apa bepa cepa depa} be } bepa test string-26.7.$noComp {tcl::prefix} -body { tcl::prefix match -exact {apa bepa cepa depa} be } -returnCodes 1 -result {bad option "be": must be apa, bepa, cepa, or depa} test string-26.8.$noComp {tcl::prefix} -body { tcl::prefix match -message wombat {apa bepa bear depa} be } -returnCodes 1 -result {ambiguous wombat "be": must be apa, bepa, bear, or depa} test string-26.9.$noComp {tcl::prefix} -body { tcl::prefix match -error {} {apa bepa bear depa} be } -returnCodes 0 -result {} test string-26.10.$noComp {tcl::prefix} -body { tcl::prefix match -error {-level 1} {apa bepa bear depa} be } -returnCodes 2 -result {ambiguous option "be": must be apa, bepa, bear, or depa} test string-26.10.1.$noComp {tcl::prefix} -setup { proc _testprefix {args} { array set opts {-a x -b y -c y} foreach {opt val} $args { set opt [tcl::prefix match -error {-level 1} {-a -b -c} $opt] set opts($opt) $val } array get opts |
︙ | ︙ | |||
1876 1877 1878 1879 1880 1881 1882 | set end [lindex [lindex [split [memory info] "\n"] 3] 3] } lappend res [expr {$end - $tmp}] } return $res } | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > | 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 | set end [lindex [lindex [split [memory info] "\n"] 3] 3] } lappend res [expr {$end - $tmp}] } return $res } test string-26.11.$noComp {tcl::prefix: testing for leaks} -body { # This test is made to stress object reference management MemStress { set table {hejj miff gurk} set item [lindex $table 1] # If not careful, this can cause a circular reference # that will cause a leak. tcl::prefix match $table $item } { # A similar case with nested lists set table2 {hejj {miff maff} gurk} set item [lindex [lindex $table2 1] 0] tcl::prefix match $table2 $item } { # A similar case with dict set table3 {hejj {miff maff} gurk2} set item [lindex [dict keys [lindex $table3 1]] 0] tcl::prefix match $table3 $item } } -constraints memory -result {0 0 0} test string-26.12.$noComp {tcl::prefix: testing for leaks} -body { # This is a memory leak test in a form that might actually happen # in real code. The shared literal "miff" causes a connection # between the item and the table. MemStress { proc stress1 {item} { set table [list hejj miff gurk] tcl::prefix match $table $item } proc stress2 {} { stress1 miff } stress2 rename stress1 {} rename stress2 {} } } -constraints memory -result 0 test string-26.13.$noComp {tcl::prefix: testing for leaks} -body { # This test is made to stress object reference management MemStress { set table [list hejj miff] set item $table set error $table # Use the same objects in all places catch { tcl::prefix match -error $error $table $item } } } -constraints memory -result {0} test string-27.1.$noComp {tcl::prefix all, too few args} -body { tcl::prefix all a } -returnCodes 1 -result {wrong # args: should be "tcl::prefix all table string"} test string-27.2.$noComp {tcl::prefix all, bad args} -body { tcl::prefix all a b c } -returnCodes 1 -result {wrong # args: should be "tcl::prefix all table string"} test string-27.3.$noComp {tcl::prefix all, bad args} -body { tcl::prefix all "{}x" str2 } -returnCodes 1 -result {list element in braces followed by "x" instead of space} test string-27.4.$noComp {tcl::prefix all} { tcl::prefix all {apa bepa cepa depa} c } cepa test string-27.5.$noComp {tcl::prefix all} { tcl::prefix all {apa bepa cepa depa} cepa } cepa test string-27.6.$noComp {tcl::prefix all} { tcl::prefix all {apa bepa cepa depa} cepax } {} test string-27.7.$noComp {tcl::prefix all} { tcl::prefix all {apa aska appa} a } {apa aska appa} test string-27.8.$noComp {tcl::prefix all} { tcl::prefix all {apa aska appa} ap } {apa appa} test string-27.9.$noComp {tcl::prefix all} { tcl::prefix all {apa aska appa} p } {} test string-27.10.$noComp {tcl::prefix all} { tcl::prefix all {apa aska appa} {} } {apa aska appa} test string-28.1.$noComp {tcl::prefix longest, too few args} -body { tcl::prefix longest a } -returnCodes 1 -result {wrong # args: should be "tcl::prefix longest table string"} test string-28.2.$noComp {tcl::prefix longest, bad args} -body { tcl::prefix longest a b c } -returnCodes 1 -result {wrong # args: should be "tcl::prefix longest table string"} test string-28.3.$noComp {tcl::prefix longest, bad args} -body { tcl::prefix longest "{}x" str2 } -returnCodes 1 -result {list element in braces followed by "x" instead of space} test string-28.4.$noComp {tcl::prefix longest} { tcl::prefix longest {apa bepa cepa depa} c } cepa test string-28.5.$noComp {tcl::prefix longest} { tcl::prefix longest {apa bepa cepa depa} cepa } cepa test string-28.6.$noComp {tcl::prefix longest} { tcl::prefix longest {apa bepa cepa depa} cepax } {} test string-28.7.$noComp {tcl::prefix longest} { tcl::prefix longest {apa aska appa} a } a test string-28.8.$noComp {tcl::prefix longest} { tcl::prefix longest {apa aska appa} ap } ap test string-28.9.$noComp {tcl::prefix longest} { tcl::prefix longest {apa bska appa} a } ap test string-28.10.$noComp {tcl::prefix longest} { tcl::prefix longest {apa bska appa} {} } {} test string-28.11.$noComp {tcl::prefix longest} { tcl::prefix longest {{} bska appa} {} } {} test string-28.12.$noComp {tcl::prefix longest} { tcl::prefix longest {apa {} appa} {} } {} test string-28.13.$noComp {tcl::prefix longest} { # Test UTF8 handling tcl::prefix longest {ax\x90 bep ax\x91} a } ax test string-29.1.$noComp {string cat, no arg} { run {string cat} } "" test string-29.2.$noComp {string cat, single arg} { set x FOO run {string compare $x [run {string cat $x}]} } 0 test string-29.3.$noComp {string cat, two args} { set x FOO run {string compare $x$x [run {string cat $x $x}]} } 0 test string-29.4.$noComp {string cat, many args} { set x FOO set n 260 set xx [run {string repeat $x $n}] set vv [run {string repeat {$x} $n}] set vvs [run {string repeat {$x } $n}] set r1 [run {string compare $xx [subst $vv]}] set r2 [run {string compare $xx [eval "run {string cat $vvs}"]}] list $r1 $r2 } {0 0} if {$noComp} { test string-29.5.$noComp {string cat, efficiency} -body { tcl::unsupported::representation [run {string cat [list x] [list]}] } -match glob -result {*no string representation} test string-29.6.$noComp {string cat, efficiency} -body { tcl::unsupported::representation [run {string cat [list] [list x]}] } -match glob -result {*no string representation} test string-29.7.$noComp {string cat, efficiency} -body { tcl::unsupported::representation [run {string cat [list x] [list] [list]}] } -match glob -result {*no string representation} test string-29.8.$noComp {string cat, efficiency} -body { tcl::unsupported::representation [run {string cat [list] [list x] [list]}] } -match glob -result {*no string representation} test string-29.9.$noComp {string cat, efficiency} -body { tcl::unsupported::representation [run {string cat [list] [list] [list x]}] } -match glob -result {*no string representation} test string-29.10.$noComp {string cat, efficiency} -body { tcl::unsupported::representation [run {string cat [list x] [list x]}] } -match glob -result {*, string representation "xx"} test string-29.11.$noComp {string cat, efficiency} -body { tcl::unsupported::representation \ [run {string cat [list x] [encoding convertto utf-8 {}]}] } -match glob -result {*no string representation} test string-29.12.$noComp {string cat, efficiency} -body { tcl::unsupported::representation \ [run {string cat [encoding convertto utf-8 {}] [list x]}] } -match glob -result {*, string representation "x"} test string-29.13.$noComp {string cat, efficiency} -body { tcl::unsupported::representation [run {string cat \ [encoding convertto utf-8 {}] [encoding convertto utf-8 {}] [list x]}] } -match glob -result {*, string representation "x"} test string-29.14.$noComp {string cat, efficiency} -setup { set e [encoding convertto utf-8 {}] } -cleanup { unset e } -body { tcl::unsupported::representation [run {string cat $e $e [list x]}] } -match glob -result {*no string representation} test string-29.15.$noComp {string cat, efficiency} -setup { set e [encoding convertto utf-8 {}] set f [encoding convertto utf-8 {}] } -cleanup { unset e f } -body { tcl::unsupported::representation [run {string cat $e $f $e $f [list x]}] } -match glob -result {*no string representation} } } # cleanup rename MemStress {} rename makeByteArray {} rename makeUnicode {} rename makeList {} rename makeShared {} catch {rename foo {}} ::tcltest::cleanupTests return # Local Variables: # mode: tcl # End: |
Deleted tests/stringComp.test.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |