1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467
|
#!perl
# This file specifies an array-of-hashes that define snippets of code that
# can be run by various measurement and profiling tools.
#
# The basic idea is that any time you add an optimisation that is intended
# to make a particular construct faster, then you should add that construct
# to this file.
#
# Under the normal test suite, the test file benchmarks.t does a basic
# compile and run of each of these snippets; not to test performance,
# but just to ensure that the code doesn't have errors.
#
# Over time, it is intended that various measurement and profiling tools
# will be written that can run selected (or all) snippets in various
# environments. These will not be run as part of a normal test suite run.
#
# It is intended that the tests in this file will be lightweight; e.g.
# a hash access, an empty function call, or a single regex match etc.
#
# This file is designed to be read in by 'do' (and in such a way that
# multiple versions of this file from different releases can be read in
# by a single process).
#
# The top-level array has name/hash pairs (we use an array rather than a
# hash so that duplicate keys can be spotted) Each name is a token that
# describes a particular test. Code will be compiled in the package named
# after the token, so it should match /^(\w|::)+$/a. It is intended that
# this can be used on the command line of tools to select particular
# tests.
# In addition, the package names are arranged into an informal hierarchy
# whose top members are (this is subject to change):
#
# call:: subroutine and method handling
# expr:: expressions: e.g. $x=1, $foo{bar}[0]
# func:: perl functions, e.g. func::sort::...
# loop:: structural code like for, while(), etc
# regex:: regular expressions
# string:: string handling
#
#
# Each hash has up to five fields:
#
# desc is a description of the test; if not present, it defaults
# to the same value as the 'code' field
#
# setup is an optional string containing setup code that is run once
#
# code is a string containing the code to run in a loop
#
# pre is an optional string containing setup code which is executed
# just before 'code' for every iteration, but whose execution
# time is not included in the result
#
# post like pre, but executed just after 'code'.
#
# So typically a benchmark tool might execute variations on something like
#
# eval "package $name; $setup; for (1..1000000) { $pre; $code; $post }"
#
# Currently the only tool that uses this file is Porting/bench.pl;
# try C<perl Porting/bench.pl --help> for more info
#
# ------
#
# Note: for the cachegrind variant, an entry like
# 'foo::bar' => {
# setup => 'SETUP',
# pre => 'PRE',
# code => 'CODE',
# post => 'POST',
# }
# creates two temporary perl sources looking like:
#
# package foo::bar;
# BEGIN { srand(0) }
# SETUP;
# for my $__loop__ (1..$ARGV[0]) {
# PRE; 1; POST;
# }
#
# and as above, but with the loop body replaced with:
#
# PRE; CODE; POST;
#
# It then pipes each of the two sources into
#
# PERL_HASH_SEED=0 valgrind [options] someperl [options] - N
#
# where N is set to 10 and then 20.
#
# It then uses the result of those four cachegrind runs to subtract out
# the perl startup and loop overheads (including SETUP, PRE and POST), leaving
# (in theory only CODE);
#
# Note that misleading results may be obtained if each iteration is
# not identical. For example with
#
# code => '$x .= "foo"',
#
# the string $x gets longer on each iteration. Similarly, a hash might be
# empty on the first iteration, but have entries on subsequent iterations.
#
# To avoid this, use 'pre' or 'post', e.g.
#
# pre => '$x = ""',
# code => '$x .= "foo"',
#
# Finally, the optional 'compile' key causes the code body to be wrapped
# in eval qw{ sub { ... }}, so that compile time rather than execution
# time is measured.
[
'call::sub::empty' => {
desc => 'function call with no args or body',
setup => 'sub f { }',
code => 'f()',
},
'call::sub::amp_empty' => {
desc => '&foo function call with no args or body',
setup => 'sub f { }; @_ = ();',
code => '&f',
},
'call::sub::args3' => {
desc => 'function call with 3 local lexical vars',
setup => 'sub f { my ($a, $b, $c) = @_; 1 }',
code => 'f(1,2,3)',
},
'call::sub::args2_ret1' => {
desc => 'function call with 2 local lex vars and 1 return value',
setup => 'my $x; sub f { my ($a, $b) = @_; $a+$b }',
code => '$x = f(1,2)',
},
'call::sub::args2_ret1temp' => {
desc => 'function call with 2 local lex vars and 1 return TEMP value',
setup => 'my $x; sub f { my ($a, $b) = @_; \$a }',
code => '$x = f(1,2)',
},
'call::sub::args3_ret3' => {
desc => 'function call with 3 local lex vars and 3 return values',
setup => 'my @a; sub f { my ($a, $b, $c) = @_; $a+$b, $c, 1 }',
code => '@a = f(1,2,3)',
},
'call::sub::args3_ret3str' => {
desc => 'function call with 3 local lex vars and 3 string return values',
setup => 'my @a; sub f { my ($a, $b, $c) = @_; my @s = ("aa","bb","cc"); @s }',
code => '@a = f(1,2,3)',
},
'call::sub::args3_ret3temp' => {
desc => 'function call with 3 local lex vars and 3 TEMP return values',
setup => 'my @a; sub f { my ($a, $b, $c) = @_; 1..3 }',
code => '@a = f(1,2,3)',
},
'call::sub::recursive' => {
desc => 'basic recursive function call',
setup => 'my $x; sub f { my ($i) = @_; $i > 0 ? $i + f($i-1) : 0 }',
code => '$x = f(1)',
},
'call::sub::scalar' => {
desc => 'sub called in scalar context',
setup => 'my $x; my @a = 1..4; sub f { @a }',
code => '$x = f()',
},
'call::goto::empty' => {
desc => 'goto &funtion with no args or body',
setup => 'sub f { goto &g } sub g {}',
code => 'f()',
},
'call::goto::args3' => {
desc => 'goto &funtion with 3 local lexical vars',
setup => 'sub f { goto &g } sub g { my ($a, $b, $c) = @_ }',
code => 'f(1,2,3)',
},
'expr::array::lex_1const_0' => {
desc => 'lexical $array[0]',
setup => 'my @a = (1)',
code => '$a[0]',
},
'expr::array::lex_1const_m1' => {
desc => 'lexical $array[-1]',
setup => 'my @a = (1)',
code => '$a[-1]',
},
'expr::array::lex_2const' => {
desc => 'lexical $array[const][const]',
setup => 'my @a = ([1,2])',
code => '$a[0][1]',
},
'expr::array::lex_2var' => {
desc => 'lexical $array[$i1][$i2]',
setup => 'my ($i1,$i2) = (0,1); my @a = ([1,2])',
code => '$a[$i1][$i2]',
},
'expr::array::ref_lex_2var' => {
desc => 'lexical $arrayref->[$i1][$i2]',
setup => 'my ($i1,$i2) = (0,1); my $r = [[1,2]]',
code => '$r->[$i1][$i2]',
},
'expr::array::ref_lex_3const' => {
desc => 'lexical $arrayref->[const][const][const]',
setup => 'my $r = [[[1,2]]]',
code => '$r->[0][0][0]',
},
'expr::array::ref_expr_lex_3const' => {
desc => '(lexical expr)->[const][const][const]',
setup => 'my $r = [[[1,2]]]',
code => '($r||0)->[0][0][0]',
},
'expr::array::pkg_1const_0' => {
desc => 'package $array[0]',
setup => '@a = (1)',
code => '$a[0]',
},
'expr::array::pkg_1const_m1' => {
desc => 'package $array[-1]',
setup => '@a = (1)',
code => '$a[-1]',
},
'expr::array::pkg_2const' => {
desc => 'package $array[const][const]',
setup => '@a = ([1,2])',
code => '$a[0][1]',
},
'expr::array::pkg_2var' => {
desc => 'package $array[$i1][$i2]',
setup => '($i1,$i2) = (0,1); @a = ([1,2])',
code => '$a[$i1][$i2]',
},
'expr::array::ref_pkg_2var' => {
desc => 'package $arrayref->[$i1][$i2]',
setup => '($i1,$i2) = (0,1); $r = [[1,2]]',
code => '$r->[$i1][$i2]',
},
'expr::array::ref_pkg_3const' => {
desc => 'package $arrayref->[const][const][const]',
setup => '$r = [[[1,2]]]',
code => '$r->[0][0][0]',
},
'expr::array::ref_expr_pkg_3const' => {
desc => '(package expr)->[const][const][const]',
setup => '$r = [[[1,2]]]',
code => '($r||0)->[0][0][0]',
},
'expr::array::lex_bool_empty' => {
desc => 'empty lexical array in boolean context',
setup => 'my @a;',
code => '!@a',
},
'expr::array::lex_bool_full' => {
desc => 'non-empty lexical array in boolean context',
setup => 'my @a = 1..10;',
code => '!@a',
},
'expr::array::lex_scalar_empty' => {
desc => 'empty lexical array in scalar context',
setup => 'my (@a, $i);',
code => '$i = @a',
},
'expr::array::lex_scalar_full' => {
desc => 'non-empty lexical array in scalar context',
setup => 'my @a = 1..10; my $i',
code => '$i = @a',
},
'expr::array::pkg_bool_empty' => {
desc => 'empty lexical array in boolean context',
setup => 'our @a;',
code => '!@a',
},
'expr::array::pkg_bool_full' => {
desc => 'non-empty lexical array in boolean context',
setup => 'our @a = 1..10;',
code => '!@a',
},
'expr::array::pkg_scalar_empty' => {
desc => 'empty lexical array in scalar context',
setup => 'our @a; my $i;',
code => '$i = @a',
},
'expr::array::pkg_scalar_full' => {
desc => 'non-empty lexical array in scalar context',
setup => 'our @a = 1..10; my $i',
code => '$i = @a',
},
'expr::arrayhash::lex_3var' => {
desc => 'lexical $h{$k1}[$i]{$k2}',
setup => 'my ($i, $k1, $k2) = (0,"foo","bar");'
. 'my %h = (foo => [ { bar => 1 } ])',
code => '$h{$k1}[$i]{$k2}',
},
'expr::arrayhash::pkg_3var' => {
desc => 'package $h{$k1}[$i]{$k2}',
setup => '($i, $k1, $k2) = (0,"foo","bar");'
. '%h = (foo => [ { bar => 1 } ])',
code => '$h{$k1}[$i]{$k2}',
},
'expr::hash::lex_1const' => {
desc => 'lexical $hash{const}',
setup => 'my %h = ("foo" => 1)',
code => '$h{foo}',
},
'expr::hash::lex_2const' => {
desc => 'lexical $hash{const}{const}',
setup => 'my %h = (foo => { bar => 1 })',
code => '$h{foo}{bar}',
},
'expr::hash::lex_2var' => {
desc => 'lexical $hash{$k1}{$k2}',
setup => 'my ($k1,$k2) = qw(foo bar); my %h = ($k1 => { $k2 => 1 })',
code => '$h{$k1}{$k2}',
},
'expr::hash::ref_lex_2var' => {
desc => 'lexical $hashref->{$k1}{$k2}',
setup => 'my ($k1,$k2) = qw(foo bar); my $r = {$k1 => { $k2 => 1 }}',
code => '$r->{$k1}{$k2}',
},
'expr::hash::ref_lex_3const' => {
desc => 'lexical $hashref->{const}{const}{const}',
setup => 'my $r = {foo => { bar => { baz => 1 }}}',
code => '$r->{foo}{bar}{baz}',
},
'expr::hash::ref_expr_lex_3const' => {
desc => '(lexical expr)->{const}{const}{const}',
setup => 'my $r = {foo => { bar => { baz => 1 }}}',
code => '($r||0)->{foo}{bar}{baz}',
},
'expr::hash::pkg_1const' => {
desc => 'package $hash{const}',
setup => '%h = ("foo" => 1)',
code => '$h{foo}',
},
'expr::hash::pkg_2const' => {
desc => 'package $hash{const}{const}',
setup => '%h = (foo => { bar => 1 })',
code => '$h{foo}{bar}',
},
'expr::hash::pkg_2var' => {
desc => 'package $hash{$k1}{$k2}',
setup => '($k1,$k2) = qw(foo bar); %h = ($k1 => { $k2 => 1 })',
code => '$h{$k1}{$k2}',
},
'expr::hash::ref_pkg_2var' => {
desc => 'package $hashref->{$k1}{$k2}',
setup => '($k1,$k2) = qw(foo bar); $r = {$k1 => { $k2 => 1 }}',
code => '$r->{$k1}{$k2}',
},
'expr::hash::ref_pkg_3const' => {
desc => 'package $hashref->{const}{const}{const}',
setup => '$r = {foo => { bar => { baz => 1 }}}',
code => '$r->{foo}{bar}{baz}',
},
'expr::hash::ref_expr_pkg_3const' => {
desc => '(package expr)->{const}{const}{const}',
setup => '$r = {foo => { bar => { baz => 1 }}}',
code => '($r||0)->{foo}{bar}{baz}',
},
'expr::hash::exists_lex_2var' => {
desc => 'lexical exists $hash{$k1}{$k2}',
setup => 'my ($k1,$k2) = qw(foo bar); my %h = ($k1 => { $k2 => 1 });',
code => 'exists $h{$k1}{$k2}',
},
'expr::hash::bool_empty' => {
desc => 'empty lexical hash in boolean context',
setup => 'my %h;',
code => '!%h',
},
'expr::hash::bool_empty_unknown' => {
desc => 'empty lexical hash in unknown context',
setup => 'my ($i, %h); sub f { if (%h) { $i++ }}',
code => 'f()',
},
'expr::hash::bool_full' => {
desc => 'non-empty lexical hash in boolean context',
setup => 'my %h = 1..10;',
code => '!%h',
},
(
map {
sprintf('expr::hash::notexists_lex_keylen%04d',$_) => {
desc => 'exists on non-key of length '. $_,
setup => 'my %h; my $key = "A" x ' . $_ . '; $h{$key."x"} = 1;',
code => 'exists $h{$key}',
},
} (
1 .. 24,
# 1,2,3,7,8,9,14,15,16,20,24,
50,
100,
1000,
)
),
(
map {
sprintf('expr::hash::exists_lex_keylen%04d',$_) => {
desc => 'exists on existing key of length '. $_,
setup => 'my %h; my $key = "A" x ' . $_ . '; $h{$key} = 1;',
code => 'exists $h{$key}',
},
} (
1 .. 24,
# 1,2,3,7,8,9,14,15,16,20,24,
50,
100,
1000,
)
),
'expr::hash::delete_lex_2var' => {
desc => 'lexical delete $hash{$k1}{$k2}',
setup => 'my ($k1,$k2) = qw(foo bar); my %h = ($k1 => { $k2 => 1 });',
code => 'delete $h{$k1}{$k2}',
},
# list assign, OP_AASSIGN
# (....) = ()
'expr::aassign::ma_empty' => {
desc => 'my array assigned empty',
setup => '',
code => 'my @a = ()',
},
'expr::aassign::lax_empty' => {
desc => 'non-empty lexical array assigned empty',
setup => 'my @a = 1..3;',
code => '@a = ()',
},
'expr::aassign::llax_empty' => {
desc => 'non-empty lexical var and array assigned empty',
setup => 'my ($x, @a) = 1..4;',
code => '($x, @a) = ()',
},
'expr::aassign::mh_empty' => {
desc => 'my hash assigned empty',
setup => '',
code => 'my %h = ()',
},
'expr::aassign::lhx_empty' => {
desc => 'non-empty lexical hash assigned empty',
setup => 'my %h = 1..4;',
code => '%h = ()',
},
'expr::aassign::llhx_empty' => {
desc => 'non-empty lexical var and hash assigned empty',
setup => 'my ($x, %h) = 1..5;',
code => '($x, %h) = ()',
},
'expr::aassign::3m_empty' => {
desc => 'three my vars assigned empty',
setup => '',
code => 'my ($x,$y,$z) = ()',
},
'expr::aassign::3l_empty' => {
desc => 'three lexical vars assigned empty',
setup => 'my ($x,$y,$z)',
code => '($x,$y,$z) = ()',
},
'expr::aassign::3lref_empty' => {
desc => 'three lexical ref vars assigned empty',
setup => 'my ($x,$y,$z); my $r = []; ',
code => '($x,$y,$z) = ($r,$r,$r); ($x,$y,$z) = ()',
},
'expr::aassign::pa_empty' => {
desc => 'package array assigned empty',
setup => '',
code => '@a = ()',
},
'expr::aassign::pax_empty' => {
desc => 'non-empty package array assigned empty',
setup => '@a = (1,2,3)',
code => '@a = ()',
},
'expr::aassign::3p_empty' => {
desc => 'three package vars assigned empty',
setup => '($x,$y,$z) = 1..3;',
code => '($x,$y,$z) = ()',
},
# (....) = (1,2,3)
'expr::aassign::ma_3c' => {
desc => 'my array assigned 3 consts',
setup => '',
code => 'my @a = (1,2,3)',
},
'expr::aassign::lax_3c' => {
desc => 'non-empty lexical array assigned 3 consts',
setup => 'my @a = 1..3;',
code => '@a = (1,2,3)',
},
'expr::aassign::llax_3c' => {
desc => 'non-empty lexical var and array assigned 3 consts',
setup => 'my ($x, @a) = 1..4;',
code => '($x, @a) = (1,2,3)',
},
'expr::aassign::mh_4c' => {
desc => 'my hash assigned 4 consts',
setup => '',
code => 'my %h = qw(a 1 b 2)',
},
'expr::aassign::lhx_4c' => {
desc => 'non-empty lexical hash assigned 4 consts',
setup => 'my %h = qw(a 1 b 2);',
code => '%h = qw(c 3 d 4)',
},
'expr::aassign::llhx_5c' => {
desc => 'non-empty lexical var and array assigned 5 consts',
setup => 'my ($x, %h) = (1, qw(a 1 b 2));',
code => '($x, %h) = (10, qw(c 3 d 4))',
},
'expr::aassign::3m_3c' => {
desc => 'three my vars assigned 3 consts',
setup => '',
code => 'my ($x,$y,$z) = (1,2,3)',
},
'expr::aassign::3l_3c' => {
desc => 'three lexical vars assigned 3 consts',
setup => 'my ($x,$y,$z)',
code => '($x,$y,$z) = (1,2,3)',
},
'expr::aassign::pa_3c' => {
desc => 'package array assigned 3 consts',
setup => '',
code => '@a = (1,2,3)',
},
'expr::aassign::pax_3c' => {
desc => 'non-empty package array assigned 3 consts',
setup => '@a = (1,2,3)',
code => '@a = (1,2,3)',
},
'expr::aassign::3p_3c' => {
desc => 'three package vars assigned 3 consts',
setup => '($x,$y,$z) = 1..3;',
code => '($x,$y,$z) = (1,2,3)',
},
# (....) = @lexical
'expr::aassign::ma_la' => {
desc => 'my array assigned lexical array',
setup => 'my @init = 1..3;',
code => 'my @a = @init',
},
'expr::aassign::lax_la' => {
desc => 'non-empty lexical array assigned lexical array',
setup => 'my @init = 1..3; my @a = 1..3;',
code => '@a = @init',
},
'expr::aassign::llax_la' => {
desc => 'non-empty lexical var and array assigned lexical array',
setup => 'my @init = 1..3; my ($x, @a) = 1..4;',
code => '($x, @a) = @init',
},
'expr::aassign::3m_la' => {
desc => 'three my vars assigned lexical array',
setup => 'my @init = 1..3;',
code => 'my ($x,$y,$z) = @init',
},
'expr::aassign::3l_la' => {
desc => 'three lexical vars assigned lexical array',
setup => 'my @init = 1..3; my ($x,$y,$z)',
code => '($x,$y,$z) = @init',
},
'expr::aassign::pa_la' => {
desc => 'package array assigned lexical array',
setup => 'my @init = 1..3;',
code => '@a = @init',
},
'expr::aassign::pax_la' => {
desc => 'non-empty package array assigned lexical array',
setup => 'my @init = 1..3; @a = @init',
code => '@a = @init',
},
'expr::aassign::3p_la' => {
desc => 'three package vars assigned lexical array',
setup => 'my @init = 1..3; ($x,$y,$z) = 1..3;',
code => '($x,$y,$z) = @init',
},
# (....) = @package
'expr::aassign::ma_pa' => {
desc => 'my array assigned package array',
setup => '@init = 1..3;',
code => 'my @a = @init',
},
'expr::aassign::lax_pa' => {
desc => 'non-empty lexical array assigned package array',
setup => '@init = 1..3; my @a = 1..3;',
code => '@a = @init',
},
'expr::aassign::llax_pa' => {
desc => 'non-empty lexical var and array assigned package array',
setup => '@init = 1..3; my ($x, @a) = 1..4;',
code => '($x, @a) = @init',
},
'expr::aassign::3m_pa' => {
desc => 'three my vars assigned package array',
setup => '@init = 1..3;',
code => 'my ($x,$y,$z) = @init',
},
'expr::aassign::3l_pa' => {
desc => 'three lexical vars assigned package array',
setup => '@init = 1..3; my ($x,$y,$z)',
code => '($x,$y,$z) = @init',
},
'expr::aassign::pa_pa' => {
desc => 'package array assigned package array',
setup => '@init = 1..3;',
code => '@a = @init',
},
'expr::aassign::pax_pa' => {
desc => 'non-empty package array assigned package array',
setup => '@init = 1..3; @a = @init',
code => '@a = @init',
},
'expr::aassign::3p_pa' => {
desc => 'three package vars assigned package array',
setup => '@init = 1..3; ($x,$y,$z) = 1..3;',
code => '($x,$y,$z) = @init',
},
# (....) = @_;
'expr::aassign::ma_defary' => {
desc => 'my array assigned @_',
setup => '@_ = 1..3;',
code => 'my @a = @_',
},
'expr::aassign::lax_defary' => {
desc => 'non-empty lexical array assigned @_',
setup => '@_ = 1..3; my @a = 1..3;',
code => '@a = @_',
},
'expr::aassign::llax_defary' => {
desc => 'non-empty lexical var and array assigned @_',
setup => '@_ = 1..3; my ($x, @a) = 1..4;',
code => '($x, @a) = @_',
},
'expr::aassign::3m_defary' => {
desc => 'three my vars assigned @_',
setup => '@_ = 1..3;',
code => 'my ($x,$y,$z) = @_',
},
'expr::aassign::3l_defary' => {
desc => 'three lexical vars assigned @_',
setup => '@_ = 1..3; my ($x,$y,$z)',
code => '($x,$y,$z) = @_',
},
'expr::aassign::pa_defary' => {
desc => 'package array assigned @_',
setup => '@_ = 1..3;',
code => '@a = @_',
},
'expr::aassign::pax_defary' => {
desc => 'non-empty package array assigned @_',
setup => '@_ = 1..3; @a = @_',
code => '@a = @_',
},
'expr::aassign::3p_defary' => {
desc => 'three package vars assigned @_',
setup => '@_ = 1..3; ($x,$y,$z) = 1..3;',
code => '($x,$y,$z) = @_',
},
# (....) = %lexical
'expr::aassign::ma_lh' => {
desc => 'my array assigned lexical hash',
setup => 'my %h = qw(aardvark 1 banana 2 cucumber 3)',
code => 'my @a = %h',
},
# (....) = ($lex1,$lex2,$lex3);
'expr::aassign::ma_3l' => {
desc => 'my array assigned lexicals',
setup => 'my ($v1,$v2,$v3) = 1..3;',
code => 'my @a = ($v1,$v2,$v3)',
},
'expr::aassign::lax_3l' => {
desc => 'non-empty lexical array assigned lexicals',
setup => 'my ($v1,$v2,$v3) = 1..3; my @a = 1..3;',
code => '@a = ($v1,$v2,$v3)',
},
'expr::aassign::llax_3l' => {
desc => 'non-empty lexical var and array assigned lexicals',
setup => 'my ($v1,$v2,$v3) = 1..3; my ($x, @a) = 1..4;',
code => '($x, @a) = ($v1,$v2,$v3)',
},
'expr::aassign::3m_3l' => {
desc => 'three my vars assigned lexicals',
setup => 'my ($v1,$v2,$v3) = 1..3;',
code => 'my ($x,$y,$z) = ($v1,$v2,$v3)',
},
'expr::aassign::3l_3l' => {
desc => 'three lexical vars assigned lexicals',
setup => 'my ($v1,$v2,$v3) = 1..3; my ($x,$y,$z)',
code => '($x,$y,$z) = ($v1,$v2,$v3)',
},
'expr::aassign::pa_3l' => {
desc => 'package array assigned lexicals',
setup => 'my ($v1,$v2,$v3) = 1..3;',
code => '@a = ($v1,$v2,$v3)',
},
'expr::aassign::pax_3l' => {
desc => 'non-empty package array assigned lexicals',
setup => 'my ($v1,$v2,$v3) = 1..3; @a = @_',
code => '@a = ($v1,$v2,$v3)',
},
'expr::aassign::3p_3l' => {
desc => 'three package vars assigned lexicals',
setup => 'my ($v1,$v2,$v3) = 1..3; ($x,$y,$z) = 1..3;',
code => '($x,$y,$z) = ($v1,$v2,$v3)',
},
# (....) = ($pkg1,$pkg2,$pkg3);
'expr::aassign::ma_3p' => {
desc => 'my array assigned 3 package vars',
setup => '($v1,$v2,$v3) = 1..3;',
code => 'my @a = ($v1,$v2,$v3)',
},
'expr::aassign::lax_3p' => {
desc => 'non-empty lexical array assigned 3 package vars',
setup => '($v1,$v2,$v3) = 1..3; my @a = 1..3;',
code => '@a = ($v1,$v2,$v3)',
},
'expr::aassign::llax_3p' => {
desc => 'non-empty lexical var and array assigned 3 package vars',
setup => '($v1,$v2,$v3) = 1..3; my ($x, @a) = 1..4;',
code => '($x, @a) = ($v1,$v2,$v3)',
},
'expr::aassign::3m_3p' => {
desc => 'three my vars assigned 3 package vars',
setup => '($v1,$v2,$v3) = 1..3;',
code => 'my ($x,$y,$z) = ($v1,$v2,$v3)',
},
'expr::aassign::3l_3p' => {
desc => 'three lexical vars assigned 3 package vars',
setup => '($v1,$v2,$v3) = 1..3; my ($x,$y,$z)',
code => '($x,$y,$z) = ($v1,$v2,$v3)',
},
'expr::aassign::pa_3p' => {
desc => 'package array assigned 3 package vars',
setup => '($v1,$v2,$v3) = 1..3;',
code => '@a = ($v1,$v2,$v3)',
},
'expr::aassign::pax_3p' => {
desc => 'non-empty package array assigned 3 package vars',
setup => '($v1,$v2,$v3) = 1..3; @a = @_',
code => '@a = ($v1,$v2,$v3)',
},
'expr::aassign::3p_3p' => {
desc => 'three package vars assigned 3 package vars',
setup => '($v1,$v2,$v3) = 1..3; ($x,$y,$z) = 1..3;',
code => '($x,$y,$z) = ($v1,$v2,$v3)',
},
# (....) = (1,2,$shared);
'expr::aassign::llax_2c1s' => {
desc => 'non-empty lexical var and array assigned 2 consts and 1 shared var',
setup => 'my ($x, @a) = 1..4;',
code => '($x, @a) = (1,2,$x)',
},
'expr::aassign::3l_2c1s' => {
desc => 'three lexical vars assigned 2 consts and 1 shared var',
setup => 'my ($x,$y,$z) = 1..3;',
code => '($x,$y,$z) = (1,2,$x)',
},
'expr::aassign::3p_2c1s' => {
desc => 'three package vars assigned 2 consts and 1 shared var',
setup => '($x,$y,$z) = 1..3;',
code => '($x,$y,$z) = (1,2,$x)',
},
# ($a,$b) = ($b,$a);
'expr::aassign::2l_swap' => {
desc => 'swap two lexical vars',
setup => 'my ($a,$b) = (1,2)',
code => '($a,$b) = ($b,$a)',
},
'expr::aassign::2p_swap' => {
desc => 'swap two package vars',
setup => '($a,$b) = (1,2)',
code => '($a,$b) = ($b,$a)',
},
'expr::aassign::2laelem_swap' => {
desc => 'swap two lexical vars',
setup => 'my @a = (1,2)',
code => '($a[0],$a[1]) = ($a[1],$a[0])',
},
# misc list assign
'expr::aassign::5l_4l1s' => {
desc => 'long list of lexical vars, 1 shared',
setup => 'my ($a,$b,$c,$d,$e) = 1..5',
code => '($a,$b,$c,$d,$e) = ($a,$a,$c,$d,$e)',
},
'expr::aassign::5p_4p1s' => {
desc => 'long list of package vars, 1 shared',
setup => '($a,$b,$c,$d,$e) = 1..5',
code => '($a,$b,$c,$d,$e) = ($a,$a,$c,$d,$e)',
},
'expr::aassign::5l_defary' => {
desc => 'long list of lexical vars to assign @_ to',
setup => '@_ = 1..5',
code => 'my ($a,$b,$c,$d,$e) = @_',
},
'expr::aassign::5l1la_defary' => {
desc => 'long list of lexical vars plus long slurp to assign @_ to',
setup => '@_ = 1..20',
code => 'my ($a,$b,$c,$d,$e,@rest) = @_',
},
'expr::aassign::1l_2l' => {
desc => 'single lexical LHS',
setup => 'my $x = 1;',
code => '(undef,$x) = ($x,$x)',
},
'expr::aassign::2l_1l' => {
desc => 'single lexical RHS',
setup => 'my $x = 1;',
code => '($x,$x) = ($x)',
},
'expr::aassign::2l_1ul' => {
desc => 'undef and single lexical RHS',
setup => 'my $x = 1;',
code => '($x,$x) = (undef, $x)',
},
'expr::aassign::2list_lex' => {
desc => 'lexical ($x, $y) = (1, 2)',
setup => 'my ($x, $y)',
code => '($x, $y) = (1, 2)',
},
'expr::aassign::lex_rv' => {
desc => 'lexical ($ref1, $ref2) = ($ref3, $ref4)',
setup => 'my ($r1, $r2, $r3, $r4);
($r1, $r2) = (($r3, $r4) = ([], []));',
code => '($r1, $r2) = ($r3, $r4)',
},
'expr::aassign::lex_rv1' => {
desc => 'lexical ($ref1, $ref2) = ($ref3, $ref4) where ref1,2 are freed',
setup => 'my ($r1, $r2);',
code => '($r1, $r2) = ([], []);',
},
'expr::aassign::boolean' => {
desc => '!(@a = @b)',
setup => 'my ($s,@a, @b); @b = (1,2)',
code => '!(@a = @b);',
},
'expr::aassign::scalar' => {
desc => '$scalar = (@a = @b)',
setup => 'my ($s, @a, @b); @b = (1,2)',
code => '$s = (@a = @b);',
},
# array assign of strings
'expr::aassign::la_3s' => {
desc => 'assign 3 strings to empty lexical array',
setup => 'my @a',
code => '@a = (); @a = qw(abc defg hijkl);',
},
'expr::aassign::la_3ts' => {
desc => 'assign 3 temp strings to empty lexical array',
setup => 'my @a',
code => '@a = (); @a = map $_, qw(abc defg hijkl);',
},
'expr::aassign::lan_3s' => {
desc => 'assign 3 strings to non-empty lexical array',
setup => 'my @a = qw(abc defg hijkl)',
code => '@a = qw(abc defg hijkl);',
},
'expr::aassign::lan_3ts' => {
desc => 'assign 3 temp strings to non-empty lexical array',
setup => 'my @a = qw(abc defg hijkl)',
code => '@a = map $_, qw(abc defg hijkl);',
},
# hash assign of strings
'expr::aassign::lh_2s' => {
desc => 'assign 2 strings to empty lexical hash',
setup => 'my %h',
code => '%h = (); %h = qw(k1 abc k2 defg);',
},
'expr::aassign::lh_2ts' => {
desc => 'assign 2 temp strings to empty lexical hash',
setup => 'my %h',
code => '%h = (); %h = map $_, qw(k1 abc k2 defg);',
},
'expr::aassign::lhn_2s' => {
desc => 'assign 2 strings to non-empty lexical hash',
setup => 'my %h = qw(k1 abc k2 defg);',
code => '%h = qw(k1 abc k2 defg);',
},
'expr::aassign::lhn_2ts' => {
desc => 'assign 2 temp strings to non-empty lexical hash',
setup => 'my %h = qw(k1 abc k2 defg);',
code => '%h = map $_, qw(k1 abc k2 defg);',
},
'expr::arith::add_lex_ii' => {
desc => 'add two integers and assign to a lexical var',
setup => 'my ($x,$y,$z) = 1..3;',
code => '$z = $x + $y',
},
'expr::arith::add_pkg_ii' => {
desc => 'add two integers and assign to a package var',
setup => 'my ($x,$y) = 1..2; $z = 3;',
code => '$z = $x + $y',
},
'expr::arith::add_lex_nn' => {
desc => 'add two NVs and assign to a lexical var',
setup => 'my ($x,$y,$z) = (1.1, 2.2, 3.3);',
code => '$z = $x + $y',
},
'expr::arith::add_pkg_nn' => {
desc => 'add two NVs and assign to a package var',
setup => 'my ($x,$y); ($x,$y,$z) = (1.1, 2.2, 3.3);',
code => '$z = $x + $y',
},
'expr::arith::add_lex_ni' => {
desc => 'add an int and an NV and assign to a lexical var',
setup => 'my ($y,$z) = (2.2, 3.3);',
pre => 'my $x = 1', # after 1st iter gets upgraded to PVNV
code => '$z = $x + $y',
},
'expr::arith::add_pkg_ni' => {
desc => 'add an int and an NV and assign to a package var',
setup => 'my ($y); ($y,$z) = (2.2, 3.3);',
pre => 'my $x = 1', # after 1st iter gets upgraded to PVNV
code => '$z = $x + $y',
},
'expr::arith::add_lex_ss' => {
desc => 'add two short strings and assign to a lexical var',
setup => 'my ($x,$y,$z) = ("1", "2", 1);',
code => '$z = $x + $y; $x = "1"; ',
},
'expr::arith::add_lex_ll' => {
desc => 'add two long strings and assign to a lexical var',
setup => 'my ($x,$y,$z) = ("12345", "23456", 1);',
code => '$z = $x + $y; $x = "12345"; ',
},
'expr::arith::sub_lex_ii' => {
desc => 'subtract two integers and assign to a lexical var',
setup => 'my ($x,$y,$z) = 1..3;',
code => '$z = $x - $y',
},
'expr::arith::sub_pkg_ii' => {
desc => 'subtract two integers and assign to a package var',
setup => 'my ($x,$y) = 1..2; $z = 3;',
code => '$z = $x - $y',
},
'expr::arith::sub_lex_nn' => {
desc => 'subtract two NVs and assign to a lexical var',
setup => 'my ($x,$y,$z) = (1.1, 2.2, 3.3);',
code => '$z = $x - $y',
},
'expr::arith::sub_pkg_nn' => {
desc => 'subtract two NVs and assign to a package var',
setup => 'my ($x,$y); ($x,$y,$z) = (1.1, 2.2, 3.3);',
code => '$z = $x - $y',
},
'expr::arith::sub_lex_ni' => {
desc => 'subtract an int and an NV and assign to a lexical var',
setup => 'my ($x,$y,$z) = (1, 2.2, 3.3);',
code => '$z = $x - $y',
},
'expr::arith::sub_pkg_ni' => {
desc => 'subtract an int and an NV and assign to a package var',
setup => 'my ($x,$y); ($x,$y,$z) = (1, 2.2, 3.3);',
code => '$z = $x - $y',
},
'expr::arith::mult_lex_ii' => {
desc => 'multiply two integers and assign to a lexical var',
setup => 'my ($x,$y,$z) = 1..3;',
code => '$z = $x * $y',
},
'expr::arith::mult_pkg_ii' => {
desc => 'multiply two integers and assign to a package var',
setup => 'my ($x,$y) = 1..2; $z = 3;',
code => '$z = $x * $y',
},
'expr::arith::mult_lex_nn' => {
desc => 'multiply two NVs and assign to a lexical var',
setup => 'my ($x,$y,$z) = (1.1, 2.2, 3.3);',
code => '$z = $x * $y',
},
'expr::arith::mult_pkg_nn' => {
desc => 'multiply two NVs and assign to a package var',
setup => 'my ($x,$y); ($x,$y,$z) = (1.1, 2.2, 3.3);',
code => '$z = $x * $y',
},
'expr::arith::mult_lex_ni' => {
desc => 'multiply an int and an NV and assign to a lexical var',
setup => 'my ($x,$y,$z) = (1, 2.2, 3.3);',
code => '$z = $x * $y',
},
'expr::arith::mult_pkg_ni' => {
desc => 'multiply an int and an NV and assign to a package var',
setup => 'my ($x,$y); ($x,$y,$z) = (1, 2.2, 3.3);',
code => '$z = $x * $y',
},
# use '!' to test SvTRUE on various classes of value
'expr::arith::not_PL_undef' => {
desc => '!undef (using PL_sv_undef)',
setup => 'my $x',
code => '$x = !undef',
},
'expr::arith::not_PL_no' => {
desc => '!($x == $y) (using PL_sv_no)',
setup => 'my ($x, $y) = (1,2); my $z;',
code => '$z = !($x == $y)',
},
'expr::arith::not_PL_zero' => {
desc => '!%h (using PL_sv_zero)',
setup => 'my ($x, %h)',
code => '$x = !%h',
},
'expr::arith::not_PL_yes' => {
desc => '!($x == $y) (using PL_sv_yes)',
setup => 'my ($x, $y) = (1,1); my $z;',
code => '$z = !($x == $y)',
},
'expr::arith::not_undef' => {
desc => '!$y where $y is undef',
setup => 'my ($x, $y)',
code => '$x = !$y',
},
'expr::arith::not_0' => {
desc => '!$x where $x is 0',
setup => 'my ($x, $y) = (0, 0)',
code => '$y = !$x',
},
'expr::arith::not_1' => {
desc => '!$x where $x is 1',
setup => 'my ($x, $y) = (1, 0)',
code => '$y = !$x',
},
'expr::arith::not_string' => {
desc => '!$x where $x is "foo"',
setup => 'my ($x, $y) = ("foo", 0)',
code => '$y = !$x',
},
'expr::arith::not_ref' => {
desc => '!$x where $s is an array ref',
setup => 'my ($x, $y) = ([], 0)',
code => '$y = !$x',
},
'expr::arith::preinc' => {
setup => 'my $x = 1;',
code => '++$x',
},
'expr::arith::predec' => {
setup => 'my $x = 1;',
code => '--$x',
},
'expr::arith::postinc' => {
desc => '$x++',
setup => 'my $x = 1; my $y',
code => '$y = $x++', # scalar context so not optimised to ++$x
},
'expr::arith::postdec' => {
desc => '$x--',
setup => 'my $x = 1; my $y',
code => '$y = $x--', # scalar context so not optimised to --$x
},
# concatenation; quite possibly optimised to OP_MULTICONCAT
'expr::concat::cl' => {
setup => 'my $lex = "abcd"',
code => '"foo" . $lex',
},
'expr::concat::lc' => {
setup => 'my $lex = "abcd"',
code => '$lex . "foo"',
},
'expr::concat::ll' => {
setup => 'my $lex1 = "abcd"; my $lex2 = "wxyz"',
code => '$lex1 . $lex2',
},
'expr::concat::l_append_c' => {
setup => 'my $lex',
pre => '$lex = "abcd"',
code => '$lex .= "foo"',
},
'expr::concat::l_append_l' => {
setup => 'my $lex1; my $lex2 = "wxyz"',
pre => '$lex1 = "abcd"',
code => '$lex1 .= $lex2',
},
'expr::concat::l_append_ll' => {
setup => 'my $lex1; my $lex2 = "pqrs"; my $lex3 = "wxyz"',
pre => '$lex1 = "abcd"',
code => '$lex1 .= $lex2 . $lex3',
},
'expr::concat::l_append_clclc' => {
setup => 'my $lex1; my $lex2 = "pqrs"; my $lex3 = "wxyz"',
pre => '$lex1 = "abcd"',
code => '$lex1 .= "-foo-$lex2-foo-$lex3-foo"',
},
'expr::concat::l_append_lll' => {
setup => 'my $lex1; my ($lex2, $lex3, $lex4) = qw(pqrs wxyz 1234)',
pre => '$lex1 = "abcd"',
code => '$lex1 .= $lex2 . $lex3 . $lex4',
},
'expr::concat::m_ll' => {
setup => 'my $lex1 = "abcd"; my $lex2 = "wxyz"',
code => 'my $lex = $lex1 . $lex2',
},
'expr::concat::m_lll' => {
setup => 'my $lex1 = "abcd"; my $lex2 = "pqrs"; my $lex3 = "wxyz"',
code => 'my $lex = $lex1 . $lex2 . $lex3',
},
'expr::concat::m_cl' => {
setup => 'my $lex1 = "abcd"',
code => 'my $lex = "const$lex1"',
},
'expr::concat::m_clclc' => {
setup => 'my $lex1 = "abcd"; my $lex2 = "wxyz"',
code => 'my $lex = "foo=$lex1 bar=$lex2\n"',
},
'expr::concat::m_clclc_long' => {
desc => 'my $lex = "foooooooooo=$lex1 baaaaaaaaar=$lex2\n" where lex1/2 are 400 chars',
setup => 'my $lex1 = "abcd" x 100; my $lex2 = "wxyz" x 100',
code => 'my $lex = "foooooooooo=$lex1 baaaaaaaaar=$lex2\n"',
},
'expr::concat::l_ll' => {
setup => 'my $lex; my $lex1 = "abcd"; my $lex2 = "wxyz"',
code => '$lex = $lex1 . $lex2',
},
'expr::concat::l_ll_ldup' => {
setup => 'my $lex1; my $lex2 = "wxyz"',
pre => '$lex1 = "abcd"',
code => '$lex1 = $lex1 . $lex2',
},
'expr::concat::l_ll_rdup' => {
setup => 'my $lex1; my $lex2 = "wxyz"',
pre => '$lex1 = "abcd"',
code => '$lex1 = $lex2 . $lex1',
},
'expr::concat::l_ll_lrdup' => {
setup => 'my $lex1',
pre => '$lex1 = "abcd"',
code => '$lex1 = $lex1 . $lex1',
},
'expr::concat::l_lll' => {
setup => 'my $lex; my $lex1 = "abcd"; my $lex2 = "pqrs"; my $lex3 = "wxyz"',
code => '$lex = $lex1 . $lex2 . $lex3',
},
'expr::concat::l_lllll' => {
setup => 'my $lex; my $lex1 = "abcd"; my $lex2 = "pqrs"; my $lex3 = "wxyz"; my $lex4 = "the quick brown fox"; my $lex5 = "to be, or not to be..."',
code => '$lex = $lex1 . $lex2 . $lex3 . $lex4 . $lex5',
},
'expr::concat::l_cl' => {
setup => 'my $lex; my $lex1 = "abcd"',
code => '$lex = "const$lex1"',
},
'expr::concat::l_clclc' => {
setup => 'my $lex; my $lex1 = "abcd"; my $lex2 = "wxyz"',
code => '$lex = "foo=$lex1 bar=$lex2\n"',
},
'expr::concat::l_clclc_long' => {
desc => '$lex = "foooooooooo=$lex1 baaaaaaaaar=$lex2\n" where lex1/2 are 400 chars',
setup => 'my $lex; my $lex1 = "abcd" x 100; my $lex2 = "wxyz" x 100',
code => '$lex = "foooooooooo=$lex1 baaaaaaaaar=$lex2\n"',
},
'expr::concat::l_clclclclclc' => {
setup => 'my $lex; my $lex1 = "abcd"; my $lex2 = "pqrs"; my $lex3 = "the quick brown fox"; my $lex4 = "to be, or not to be..."',
code => '$lex = "foo1=$lex1 foo2=$lex2 foo3=$lex3 foo4=$lex4\n"',
},
'expr::concat::g_append_c' => {
setup => 'our $pkg',
pre => '$pkg = "abcd"',
code => '$pkg .= "foo"',
},
'expr::concat::g_append_l' => {
setup => 'our $pkg; my $lex1 = "wxyz"',
pre => '$pkg = "abcd"',
code => '$pkg .= $lex1',
},
'expr::concat::g_append_ll' => {
setup => 'our $pkg; my $lex1 = "pqrs"; my $lex2 = "wxyz"',
pre => '$pkg = "abcd"',
code => '$pkg .= $lex1 . $lex2',
},
'expr::concat::g_append_clclc' => {
setup => 'our $pkg; my $lex1 = "pqrs"; my $lex2 = "wxyz"',
pre => '$pkg = "abcd"',
code => '$pkg .= "-foo-$lex1-foo-$lex2-foo-"',
},
'expr::concat::g_ll' => {
setup => 'our $pkg; my $lex1 = "abcd"; my $lex2 = "wxyz"',
code => '$pkg = $lex1 . $lex2',
},
'expr::concat::g_gl_ldup' => {
setup => 'our $pkg; my $lex2 = "wxyz"',
pre => '$pkg = "abcd"',
code => '$pkg = $pkg . $lex2',
},
'expr::concat::g_lg_rdup' => {
setup => 'our $pkg; my $lex1 = "wxyz"',
pre => '$pkg = "abcd"',
code => '$pkg = $lex1 . $pkg',
},
'expr::concat::g_gg_lrdup' => {
setup => 'our $pkg',
pre => '$pkg = "abcd"',
code => '$pkg = $pkg . $pkg',
},
'expr::concat::g_lll' => {
setup => 'our $pkg; my $lex1 = "abcd"; my $lex2 = "pqrs"; my $lex3 = "wxyz"',
code => '$pkg = $lex1 . $lex2 . $lex3',
},
'expr::concat::g_cl' => {
setup => 'our $pkg; my $lex1 = "abcd"',
code => '$pkg = "const$lex1"',
},
'expr::concat::g_clclc' => {
setup => 'our $pkg; my $lex1 = "abcd"; my $lex2 = "wxyz"',
code => '$pkg = "foo=$lex1 bar=$lex2\n"',
},
'expr::concat::g_clclc_long' => {
desc => '$pkg = "foooooooooo=$lex1 baaaaaaaaar=$lex2\n" where lex1/2 are 400 chars',
setup => 'our $pkg; my $lex1 = "abcd" x 100; my $lex2 = "wxyz" x 100',
code => '$pkg = "foooooooooo=$lex1 baaaaaaaaar=$lex2\n"',
},
'expr::concat::utf8_uuu' => {
desc => 'my $s = $a.$b.$c where all args are utf8',
setup => 'my $s; my $a = "ab\x{100}cde"; my $b = "\x{101}fghij"; my $c = "\x{102}klmn"',
code => '$s = $a.$b.$c',
},
'expr::concat::utf8_suu' => {
desc => 'my $s = "foo=$a bar=$b baz=$c" where $b,$c are utf8',
setup => 'my $s; my $a = "abcde"; my $b = "\x{100}fghij"; my $c = "\x{101}klmn"',
code => '$s = "foo=$a bar=$b baz=$c"',
},
'expr::concat::utf8_usu' => {
desc => 'my $s = "foo=$a bar=$b baz=$c" where $a,$c are utf8',
setup => 'my $s; my $a = "ab\x{100}cde"; my $b = "fghij"; my $c = "\x{101}klmn"',
code => '$s = "foo=$a bar=$b baz=$c"',
},
'expr::concat::utf8_usx' => {
desc => 'my $s = "foo=$a bar=$b baz=$c" where $a is utf8, $c has 0x80',
setup => 'my $s; my $a = "ab\x{100}cde"; my $b = "fghij"; my $c = "\x80\x81klmn"',
code => '$s = "foo=$a bar=$b baz=$c"',
},
'expr::concat::utf8_s_append_uuu' => {
desc => '$s .= $a.$b.$c where all RH args are utf8',
setup => 'my $s; my $a = "ab\x{100}cde"; my $b = "\x{101}fghij"; my $c = "\x{102}klmn"',
pre => '$s = "abcd"',
code => '$s .= $a.$b.$c',
},
'expr::concat::utf8_s_append_suu' => {
desc => '$s .= "foo=$a bar=$b baz=$c" where $b,$c are utf8',
setup => 'my $s; my $a = "abcde"; my $b = "\x{100}fghij"; my $c = "\x{101}klmn"',
pre => '$s = "abcd"',
code => '$s .= "foo=$a bar=$b baz=$c"',
},
'expr::concat::utf8_s_append_usu' => {
desc => '$s .= "foo=$a bar=$b baz=$c" where $a,$c are utf8',
setup => 'my $s; my $a = "ab\x{100}cde"; my $b = "fghij"; my $c = "\x{101}klmn"',
pre => '$s = "abcd"',
code => '$s .= "foo=$a bar=$b baz=$c"',
},
'expr::concat::utf8_s_append_usx' => {
desc => '$s .= "foo=$a bar=$b baz=$c" where $a is utf8, $c has 0x80',
setup => 'my $s; my $a = "ab\x{100}cde"; my $b = "fghij"; my $c = "\x80\x81klmn"',
pre => '$s = "abcd"',
code => '$s .= "foo=$a bar=$b baz=$c"',
},
'expr::concat::utf8_u_append_uuu' => {
desc => '$s .= $a.$b.$c where all args are utf8',
setup => 'my $s; my $a = "ab\x{100}cde"; my $b = "\x{101}fghij"; my $c = "\x{102}klmn"',
pre => '$s = "\x{100}wxyz"',
code => '$s .= $a.$b.$c',
},
'expr::concat::utf8_u_append_suu' => {
desc => '$s .= "foo=$a bar=$b baz=$c" where $s,$b,$c are utf8',
setup => 'my $s; my $a = "abcde"; my $b = "\x{100}fghij"; my $c = "\x{101}klmn"',
pre => '$s = "\x{100}wxyz"',
code => '$s .= "foo=$a bar=$b baz=$c"',
},
'expr::concat::utf8_u_append_usu' => {
desc => '$s .= "foo=$a bar=$b baz=$c" where $s,$a,$c are utf8',
setup => 'my $s; my $a = "ab\x{100}cde"; my $b = "fghij"; my $c = "\x{101}klmn"',
pre => '$s = "\x{100}wxyz"',
code => '$s .= "foo=$a bar=$b baz=$c"',
},
'expr::concat::utf8_u_append_usx' => {
desc => '$s .= "foo=$a bar=$b baz=$c" where $s,$a are utf8, $c has 0x80',
setup => 'my $s; my $a = "ab\x{100}cde"; my $b = "fghij"; my $c = "\x80\x81klmn"',
pre => '$s = "\x{100}wxyz"',
code => '$s .= "foo=$a bar=$b baz=$c"',
},
'expr::concat::nested_mutator' => {
setup => 'my $lex1; my ($lex2, $lex3, $lex4) = qw(abcd pqrs wxyz)',
pre => '$lex1 = "QPR"',
code => '(($lex1 .= $lex2) .= $lex3) .= $lex4',
},
# concatenation with magic vars;
# quite possibly optimised to OP_MULTICONCAT
'expr::concat::mg::cM' => {
setup => '"abcd" =~ /(.*)/',
code => '"foo" . $1',
},
'expr::concat::mg::Mc' => {
setup => '"abcd" =~ /(.*)/',
code => '$1 . "foo"',
},
'expr::concat::mg::MM' => {
setup => '"abcd" =~ /(.*)/',
code => '$1 . $1',
},
'expr::concat::mg::l_append_M' => {
setup => 'my $lex; "abcd" =~ /(.*)/;',
pre => '$lex = "abcd"',
code => '$lex .= $1',
},
'expr::concat::mg::l_append_MM' => {
setup => 'my $lex; "abcd" =~ /(.*)/;',
pre => '$lex = "abcd"',
code => '$lex .= $1 .$1',
},
'expr::concat::mg::l_append_cMcMc' => {
setup => 'my $lex; "abcd" =~ /(.*)/;',
pre => '$lex = "abcd"',
code => '$lex .= "-foo-$1-foo-$1-foo"',
},
'expr::concat::mg::l_append_MMM' => {
setup => 'my $lex; "abcd" =~ /(.*)/;',
pre => '$lex = "abcd"',
code => '$lex .= $1 .$1 . $1',
},
'expr::concat::mg::m_MM' => {
setup => '"abcd" =~ /(.*)/;',
code => 'my $lex = $1 . $1',
},
'expr::concat::mg::m_MMM' => {
setup => '"abcd" =~ /(.*)/;',
code => 'my $lex = $1 . $1 . $1',
},
'expr::concat::mg::m_cL' => {
setup => '"abcd" =~ /(.*)/;',
code => 'my $lex = "const$1"',
},
'expr::concat::mg::m_cMcMc' => {
setup => '"abcd" =~ /(.*)/;',
code => 'my $lex = "foo=$1 bar=$1\n"',
},
'expr::concat::mg::m_cMcMc_long' => {
desc => 'my $lex = "foooooooooo=$1 baaaaaaaaar=$1\n" where $1 is 400 chars',
setup => 'my $s = "abcd" x 100; $s =~ /(.*)/;',
code => 'my $lex = "foooooooooo=$1 baaaaaaaaar=$1\n"',
},
'expr::concat::mg::l_MM' => {
setup => 'my $lex; "abcd" =~ /(.*)/;',
code => '$lex = $1 . $1',
},
'expr::concat::mg::l_lM_ldup' => {
setup => 'my $lex1; "abcd" =~ /(.*)/;',
pre => '$lex1 = "abcd"',
code => '$lex1 = $lex1 . $1',
},
'expr::concat::mg::l_Ml_rdup' => {
setup => 'my $lex1; "abcd" =~ /(.*)/;',
pre => '$lex1 = "abcd"',
code => '$lex1 = $1 . $lex1',
},
'expr::concat::mg::l_MMM' => {
setup => 'my $lex; "abcd" =~ /(.*)/;',
code => '$lex = $1 . $1 . $1',
},
'expr::concat::mg::l_MMMMM' => {
setup => 'my $lex; "abcd" =~ /(.*)/;',
code => '$lex = $1 . $1 . $1 . $1 . $1',
},
'expr::concat::mg::l_cM' => {
setup => 'my $lex; "abcd" =~ /(.*)/;',
code => '$lex = "const$1"',
},
'expr::concat::mg::l_cMcMc' => {
setup => 'my $lex; "abcd" =~ /(.*)/;',
code => '$lex = "foo=$1 bar=$1\n"',
},
'expr::concat::mg::l_cMcMc_long' => {
desc => '$lex = "foooooooooo=$1 baaaaaaaaar=$1\n" where $1 is 400 chars',
setup => 'my $s = "abcd" x 100; $s =~ /(.*)/;',
code => '$lex = "foooooooooo=$1 baaaaaaaaar=$1\n"',
},
'expr::concat::mg::l_cMcMcMcMcMc' => {
setup => 'my $lex; "abcd" =~ /(.*)/;',
code => '$lex = "foo1=$1 foo2=$1 foo3=$1 foo4=$1\n"',
},
'expr::concat::mg::g_append_M' => {
setup => 'our $pkg; "abcd" =~ /(.*)/;',
pre => '$pkg = "abcd"',
code => '$pkg .= $1',
},
'expr::concat::mg::g_append_MM' => {
setup => 'our $pkg; "abcd" =~ /(.*)/;',
pre => '$pkg = "abcd"',
code => '$pkg .= $1',
code => '$pkg .= $1 . $1',
},
'expr::concat::mg::g_append_cMcMc' => {
setup => 'our $pkg; "abcd" =~ /(.*)/;',
pre => '$pkg = "abcd"',
code => '$pkg .= "-foo-$1-foo-$1-foo-"',
},
'expr::concat::mg::g_MM' => {
setup => 'our $pkg; "abcd" =~ /(.*)/;',
code => '$pkg = $1 . $1',
},
'expr::concat::mg::g_gM_ldup' => {
setup => 'our $pkg; "abcd" =~ /(.*)/;',
pre => '$pkg = "abcd"',
code => '$pkg = $pkg . $1',
},
'expr::concat::mg::g_Mg_rdup' => {
setup => 'our $pkg; "abcd" =~ /(.*)/;',
pre => '$pkg = "abcd"',
code => '$pkg = $1 . $pkg',
},
'expr::concat::mg::g_MMM' => {
setup => 'our $pkg; "abcd" =~ /(.*)/;',
code => '$pkg = $1 . $1 . $1',
},
'expr::concat::mg::g_cM' => {
setup => 'our $pkg; "abcd" =~ /(.*)/;',
code => '$pkg = "const$1"',
},
'expr::concat::mg::g_cMcMc' => {
setup => 'our $pkg; "abcd" =~ /(.*)/;',
code => '$pkg = "foo=$1 bar=$1\n"',
},
'expr::concat::mg::g_cMcMc_long' => {
desc => '$lex = "foooooooooo=$1 baaaaaaaaar=$1\n" where $1 is 400 chars',
setup => 'our $pkg; my $s = "abcd" x 100; $s =~ /(.*)/;',
code => '$pkg = "foooooooooo=$1 baaaaaaaaar=$1\n"',
},
'expr::concat::mg::utf8_uuu' => {
desc => 'my $s = $1.$1.$1 where $1 utf8',
setup => 'my $s; "ab\x{100}cde" =~ /(.*)/;',
code => '$s = $1.$1.$1',
},
'expr::concat::mg::utf8_suu' => {
desc => 'my $s = "foo=$a bar=$1 baz=$1" where $1 is utf8',
setup => 'my $s; my $a = "abcde"; "ab\x{100}cde" =~ /(.*)/;',
code => '$s = "foo=$a bar=$1 baz=$1"',
},
# OP_MULTICONCAT with magic within s///g - see GH #21360
'expr::concat::mg::subst1_1' => {
desc => 's/(.)/$1-/g, 1 iteration',
pre => '$_ = "a"',
code => 's/(.)/$1-/g',
},
'expr::concat::mg::subst1_2' => {
desc => 's/(.)/$1-/g, 2 iterations',
pre => '$_ = "aa"',
code => 's/(.)/$1-/g',
},
'expr::concat::mg::subst1_5' => {
desc => 's/(.)/$1-/g, 5 iterations',
pre => '$_ = "aaaaa"',
code => 's/(.)/$1-/g',
},
'expr::concat::mg::subst2_1' => {
desc => 's/(.)/$1-$1/g, 1 iteration',
pre => '$_ = "a"',
code => 's/(.)/$1-/g',
},
'expr::concat::mg::subst3_1' => {
desc => 's/(.)/$1-$1-$1/g, 1 iteration',
pre => '$_ = "a"',
code => 's/(.)/$1-$1-$1/g',
},
# scalar assign, OP_SASSIGN
'expr::sassign::undef_lex' => {
setup => 'my $x',
code => '$x = undef',
},
'expr::sassign::undef_lex_direc' => {
setup => 'my $x',
code => 'undef $x',
},
'expr::sassign::undef_my_lex' => {
setup => '',
code => 'my $x = undef',
},
'expr::sassign::undef_my_lex_direc' => {
setup => '',
code => 'undef my $x',
},
'expr::sassign::anonlist' => {
setup => '',
code => '$x = []'
},
'expr::sassign::anonlist_lex' => {
setup => 'my $x',
code => '$x = []'
},
'expr::sassign::my_anonlist_lex' => {
setup => '',
code => 'my $x = []'
},
'expr::sassign::anonhash' => {
setup => '',
code => '$x = {}'
},
'expr::sassign::anonhash_lex' => {
setup => 'my $x',
code => '$x = {}'
},
'expr::sassign::my_anonhash_lex' => {
setup => '',
code => 'my $x = {}'
},
'expr::sassign::my_conststr' => {
setup => '',
code => 'my $x = "abc"',
},
'expr::sassign::scalar_lex_int' => {
desc => 'lexical $x = 1',
setup => 'my $x',
code => '$x = 1',
},
'expr::sassign::scalar_lex_str' => {
desc => 'lexical $x = "abc"',
setup => 'my $x',
code => '$x = "abc"',
},
'expr::sassign::scalar_lex_strint' => {
desc => 'lexical $x = 1 where $x was previously a string',
setup => 'my $x = "abc"',
code => '$x = 1',
},
'expr::sassign::scalar_lex_intstr' => {
desc => 'lexical $x = "abc" where $x was previously an int',
setup => 'my $x = 1;',
code => '$x = "abc"',
},
'expr::sassign::lex_rv' => {
desc => 'lexical $ref1 = $ref2;',
setup => 'my $r1 = []; my $r = $r1;',
code => '$r = $r1;',
},
'expr::sassign::lex_rv1' => {
desc => 'lexical $ref1 = $ref2; where $$ref1 gets freed',
setup => 'my $r1 = []; my $r',
code => '$r = []; $r = $r1;',
},
'expr::sassign::aelemfast_lex_assign' => {
desc => 'lexical $x[0] = 1',
setup => 'my @x',
code => '$x[0] = 1',
},
'expr::sassign::aelemfast_lex_assign_ref' => {
desc => 'lexical $x[0] = []',
setup => 'my @x',
code => '$x[0] = []',
},
'expr::sassign::aelemfast_lex_assign_deref' => {
desc => 'lexical $x[0][1]',
setup => 'my @x = ([1,2])',
code => '$x[0][1] = 1',
},
'expr::sassign::bless_lex' => {
setup => 'my $x',
code => '$x = bless {}, "X"'
},
'func::grep::bool0' => {
desc => 'grep returning 0 items in boolean context',
setup => 'my @a;',
code => '!grep $_, @a;',
},
'func::grep::bool1' => {
desc => 'grep returning 1 item in boolean context',
setup => 'my @a =(1);',
code => '!grep $_, @a;',
},
'func::grep::scalar0' => {
desc => 'returning 0 items in scalar context',
setup => 'my $g; my @a;',
code => '$g = grep $_, @a;',
},
'func::grep::scalar1' => {
desc => 'returning 1 item in scalar context',
setup => 'my $g; my @a =(1);',
code => '$g = grep $_, @a;',
},
# (index() == -1) and variants optimise away the op_const and op_eq
# and any assignment to a lexical var
'func::index::bool' => {
desc => '(index() == -1) for match',
setup => 'my $x = "aaaab"',
code => 'index($x, "b") == -1',
},
'func::index::bool_fail' => {
desc => '(index() == -1) for no match',
setup => 'my $x = "aaaab"',
code => 'index($x, "c") == -1',
},
'func::index::lex_bool' => {
desc => '$lex = (index() == -1) for match',
setup => 'my $r; my $x = "aaaab"',
code => '$r = index($x, "b") == -1',
},
'func::index::lex_bool_fail' => {
desc => '$lex = (index() == -1) for no match',
setup => 'my $r; my $x = "aaaab"',
code => '$r = index($x, "c") == -1',
},
# using a const string as second arg to index triggers using FBM.
# the FBM matcher special-cases 1,2-byte strings.
#
'func::index::short_const1' => {
desc => 'index of a short string against a 1 char const substr',
setup => 'my $x = "aaaab"',
code => 'index $x, "b"',
},
'func::index::long_const1' => {
desc => 'index of a long string against a 1 char const substr',
setup => 'my $x = "a" x 1000 . "b"',
code => 'index $x, "b"',
},
'func::index::short_const2aabc_bc' => {
desc => 'index of a short string against a 2 char const substr',
setup => 'my $x = "aaaabc"',
code => 'index $x, "bc"',
},
'func::index::long_const2aabc_bc' => {
desc => 'index of a long string against a 2 char const substr',
setup => 'my $x = "a" x 1000 . "bc"',
code => 'index $x, "bc"',
},
'func::index::long_const2aa_ab' => {
desc => 'index of a long string aaa.. against const substr "ab"',
setup => 'my $x = "a" x 1000',
code => 'index $x, "ab"',
},
'func::index::long_const2bb_ab' => {
desc => 'index of a long string bbb.. against const substr "ab"',
setup => 'my $x = "b" x 1000',
code => 'index $x, "ab"',
},
'func::index::long_const2aa_bb' => {
desc => 'index of a long string aaa.. against const substr "bb"',
setup => 'my $x = "a" x 1000',
code => 'index $x, "bb"',
},
# this one is designed to be pathological
'func::index::long_const2ab_aa' => {
desc => 'index of a long string abab.. against const substr "aa"',
setup => 'my $x = "ab" x 500',
code => 'index $x, "aa"',
},
# near misses with gaps, 1st letter
'func::index::long_const2aaxx_xy' => {
desc => 'index of a long string with "xx"s against const substr "xy"',
setup => 'my $x = "aaaaaaaaxx" x 100',
code => 'index $x, "xy"',
},
# near misses with gaps, 2nd letter
'func::index::long_const2aayy_xy' => {
desc => 'index of a long string with "yy"s against const substr "xy"',
setup => 'my $x = "aaaaaaaayy" x 100',
code => 'index $x, "xy"',
},
# near misses with gaps, duplicate letter
'func::index::long_const2aaxy_xx' => {
desc => 'index of a long string with "xy"s against const substr "xx"',
setup => 'my $x = "aaaaaaaaxy" x 100',
code => 'index $x, "xx"',
},
# alternating near misses with gaps
'func::index::long_const2aaxxaayy_xy' => {
desc => 'index of a long string with "xx/yy"s against const substr "xy"',
setup => 'my $x = "aaaaaaaaxxbbbbbbbbyy" x 50',
code => 'index $x, "xy"',
},
'func::index::short_const3aabcd_bcd' => {
desc => 'index of a short string against a 3 char const substr',
setup => 'my $x = "aaaabcd"',
code => 'index $x, "bcd"',
},
'func::index::long_const3aabcd_bcd' => {
desc => 'index of a long string against a 3 char const substr',
setup => 'my $x = "a" x 1000 . "bcd"',
code => 'index $x, "bcd"',
},
'func::index::long_const3ab_abc' => {
desc => 'index of a long string of "ab"s against a 3 char const substr "abc"',
setup => 'my $x = "ab" x 500',
code => 'index $x, "abc"',
},
'func::index::long_const3bc_abc' => {
desc => 'index of a long string of "bc"s against a 3 char const substr "abc"',
setup => 'my $x = "bc" x 500',
code => 'index $x, "abc"',
},
'func::index::utf8_position_1' => {
desc => 'index of a utf8 string, matching at position 1',
setup => 'my $x = "abc". chr(0x100); chop $x',
code => 'index $x, "b"',
},
# SUBSTR
'func::substr::nibble_void' => {
desc => 'substr with a zero offset, empty replacement pattern (void)',
setup => 'my $z = "JAPH"x1000',
code => 'substr($z, 0, 2, "")',
},
'func::substr::nibble_lex' => {
desc => 'substr with a zero offset, empty replacement pattern (lex assign)',
setup => 'my $x; my $z = "JAPH"x1000',
code => '$x = substr($z, 0, 2, "")',
},
'func::substr::nibble_gvsv' => {
desc => 'substr with a zero offset, empty replacement pattern (global assign)',
setup => 'our $x; my $z = "JAPH"x1000',
code => '$x = substr($z, 0, 2, "")',
},
# JOIN
'func::join::empty_l_ll' => {
setup => 'my $lex; my $lex1 = "abcd"; my $lex2 = "wxyz"',
code => '$lex = join "", $lex1, $lex2',
},
# KEYS
'func::keys::lex::void_cxt_empty' => {
desc => ' keys() on an empty lexical hash in void context',
setup => 'my %h = ()',
code => 'keys %h',
},
'func::keys::lex::void_cxt' => {
desc => ' keys() on a non-empty lexical hash in void context',
setup => 'my %h = qw(aardvark 1 banana 2 cucumber 3)',
code => 'keys %h',
},
'func::keys::lex::bool_cxt_empty' => {
desc => ' keys() on an empty lexical hash in bool context',
setup => 'my %h = ()',
code => '!keys %h',
},
'func::keys::lex::bool_cxt' => {
desc => ' keys() on a non-empty lexical hash in bool context',
setup => 'my %h = qw(aardvark 1 banana 2 cucumber 3)',
code => '!keys %h',
},
'func::keys::lex::scalar_cxt_empty' => {
desc => ' keys() on an empty lexical hash in scalar context',
setup => 'my $k; my %h = ()',
code => '$k = keys %h',
},
'func::keys::lex::scalar_cxt' => {
desc => ' keys() on a non-empty lexical hash in scalar context',
setup => 'my $k; my %h = qw(aardvark 1 banana 2 cucumber 3)',
code => '$k = keys %h',
},
'func::keys::lex::list_cxt_empty' => {
desc => ' keys() on an empty lexical hash in list context',
setup => 'my %h = ()',
code => '() = keys %h',
},
'func::keys::lex::list_cxt' => {
desc => ' keys() on a non-empty lexical hash in list context',
setup => 'my %h = qw(aardvark 1 banana 2 cucumber 3)',
code => '() = keys %h',
},
'func::keys::pkg::void_cxt_empty' => {
desc => ' keys() on an empty package hash in void context',
setup => 'our %h = ()',
code => 'keys %h',
},
'func::keys::pkg::void_cxt' => {
desc => ' keys() on a non-empty package hash in void context',
setup => 'our %h = qw(aardvark 1 banana 2 cucumber 3)',
code => 'keys %h',
},
'func::keys::pkg::bool_cxt_empty' => {
desc => ' keys() on an empty package hash in bool context',
setup => 'our %h = ()',
code => '!keys %h',
},
'func::keys::pkg::bool_cxt' => {
desc => ' keys() on a non-empty package hash in bool context',
setup => 'our %h = qw(aardvark 1 banana 2 cucumber 3)',
code => '!keys %h',
},
'func::keys::pkg::scalar_cxt_empty' => {
desc => ' keys() on an empty package hash in scalar context',
setup => 'my $k; our %h = ()',
code => '$k = keys %h',
},
'func::keys::pkg::scalar_cxt' => {
desc => ' keys() on a non-empty package hash in scalar context',
setup => 'my $k; our %h = qw(aardvark 1 banana 2 cucumber 3)',
code => '$k = keys %h',
},
'func::keys::pkg::list_cxt_empty' => {
desc => ' keys() on an empty package hash in list context',
setup => 'our %h = ()',
code => '() = keys %h',
},
'func::keys::pkg::list_cxt' => {
desc => ' keys() on a non-empty package hash in list context',
setup => 'our %h = qw(aardvark 1 banana 2 cucumber 3)',
code => '() = keys %h',
},
'func::length::bool0' => {
desc => 'length==0 in boolean context',
setup => 'my $s = "";',
code => '!length($s);',
},
'func::length::bool10' => {
desc => 'length==10 in boolean context',
setup => 'my $s = "abcdefghijk";',
code => '!length($s);',
},
'func::length::scalar10' => {
desc => 'length==10 in scalar context',
setup => 'my $p; my $s = "abcdefghijk";',
code => '$p = length($s);',
},
'func::length::bool0_utf8' => {
desc => 'utf8 string length==0 in boolean context',
setup => 'my $s = "\x{100}"; chop $s;',
code => '!length($s);',
},
'func::length::bool10_utf8' => {
desc => 'utf8 string length==10 in boolean context',
setup => 'my $s = "abcdefghij\x{100}";',
code => '!length($s);',
},
'func::length::scalar10_utf8' => {
desc => 'utf8 string length==10 in scalar context',
setup => 'my $p; my $s = "abcdefghij\x{100}";',
code => '$p = length($s);',
},
'func::pos::bool0' => {
desc => 'pos==0 in boolean context',
setup => 'my $s = "abc"; pos($s) = 0',
code => '!pos($s);',
},
'func::pos::bool10' => {
desc => 'pos==10 in boolean context',
setup => 'my $s = "abcdefghijk"; pos($s) = 10',
code => '!pos($s);',
},
'func::pos::scalar10' => {
desc => 'pos==10 in scalar context',
setup => 'my $p; my $s = "abcdefghijk"; pos($s) = 10',
code => '$p = pos($s);',
},
# func::print::iv_stringify should outperform func::print::iv_strings
'func::print::iv_stringify' => {
desc => 'do_print stringification of SVt_IV integers',
setup => 'open(my $fh, ">", \$x) or die $!;',
code => 'print $fh 1,2,3,4,5,6,7,8,9,0;',
},
'func::print::iv_strings' => {
desc => 'do_print pre-stringified SVt_IV integers',
setup => 'open(my $fh, ">", \$x) or die $!;',
code => 'print $fh "1","2","3","4","5","6","7","8","9","0";',
},
'func::ref::notaref_bool' => {
desc => 'ref($notaref) in boolean context',
setup => 'my $r = "boo"',
code => '!ref $r',
},
'func::ref::ref_bool' => {
desc => 'ref($ref) in boolean context',
setup => 'my $r = []',
code => '!ref $r',
},
'func::ref::blessedref_bool' => {
desc => 'ref($blessed_ref) in boolean context',
setup => 'my $r = bless []',
code => '!ref $r',
},
'func::ref::notaref' => {
desc => 'ref($notaref) in scalar context',
setup => 'my $x; my $r = "boo"',
code => '$x = ref $r',
},
'func::ref::ref' => {
desc => 'ref($ref) in scalar context',
setup => 'my $x; my $r = []',
code => '$x = ref $r',
},
'func::ref::blessedref' => {
desc => 'ref($blessed_ref) in scalar context',
setup => 'my $x; my $r = bless []',
code => '$x = ref $r',
},
'func::sort::num' => {
desc => 'plain numeric sort',
setup => 'my (@a, @b); @a = reverse 1..10;',
code => '@b = sort { $a <=> $b } @a',
},
'func::sort::num_block' => {
desc => 'codeblock numeric sort',
setup => 'my (@a, @b); @a = reverse 1..10;',
code => '@b = sort { $a + 1 <=> $b + 1 } @a',
},
'func::sort::num_fn' => {
desc => 'function numeric sort',
setup => 'sub f { $a + 1 <=> $b + 1 } my (@a, @b); @a = reverse 1..10;',
code => '@b = sort f @a',
},
'func::sort::str' => {
desc => 'plain string sort',
setup => 'my (@a, @b); @a = reverse "a".."j";',
code => '@b = sort { $a cmp $b } @a',
},
'func::sort::str_block' => {
desc => 'codeblock string sort',
setup => 'my (@a, @b); @a = reverse "a".."j";',
code => '@b = sort { ($a . "") cmp ($b . "") } @a',
},
'func::sort::str_fn' => {
desc => 'function string sort',
setup => 'sub f { ($a . "") cmp ($b . "") } my (@a, @b); @a = reverse "a".."j";',
code => '@b = sort f @a',
},
'func::sort::num_inplace' => {
desc => 'plain numeric sort in-place',
setup => 'my @a = reverse 1..10;',
code => '@a = sort { $a <=> $b } @a',
},
'func::sort::num_block_inplace' => {
desc => 'codeblock numeric sort in-place',
setup => 'my @a = reverse 1..10;',
code => '@a = sort { $a + 1 <=> $b + 1 } @a',
},
'func::sort::num_fn_inplace' => {
desc => 'function numeric sort in-place',
setup => 'sub f { $a + 1 <=> $b + 1 } my @a = reverse 1..10;',
code => '@a = sort f @a',
},
'func::sort::str_inplace' => {
desc => 'plain string sort in-place',
setup => 'my @a = reverse "a".."j";',
code => '@a = sort { $a cmp $b } @a',
},
'func::sort::str_block_inplace' => {
desc => 'codeblock string sort in-place',
setup => 'my @a = reverse "a".."j";',
code => '@a = sort { ($a . "") cmp ($b . "") } @a',
},
'func::sort::str_fn_inplace' => {
desc => 'function string sort in-place',
setup => 'sub f { ($a . "") cmp ($b . "") } my @a = reverse "a".."j";',
code => '@a = sort f @a',
},
'func::split::vars' => {
desc => 'split into two lexical vars',
setup => 'my $s = "abc:def";',
code => 'my ($x, $y) = split /:/, $s, 2;',
},
'func::split::array' => {
desc => 'split into a lexical array',
setup => 'my @a; my $s = "abc:def";',
code => '@a = split /:/, $s, 2;',
},
'func::split::myarray' => {
desc => 'split into a lexical array declared in the assign',
setup => 'my $s = "abc:def";',
code => 'my @a = split /:/, $s, 2;',
},
'func::split::arrayexpr' => {
desc => 'split into an @{$expr} ',
setup => 'my $s = "abc:def"; my $r = []',
code => '@$r = split /:/, $s, 2;',
},
'func::split::arraylist' => {
desc => 'split into an array with extra arg',
setup => 'my @a; my $s = "abc:def";',
code => '@a = (split(/:/, $s, 2), 1);',
},
# SPRINTF
'func::sprintf::d' => {
desc => '%d',
setup => 'my $s; my $a1 = 1234;',
code => '$s = sprintf "%d", $a1',
},
'func::sprintf::d8' => {
desc => '%8d',
setup => 'my $s; my $a1 = 1234;',
code => '$s = sprintf "%8d", $a1',
},
'func::sprintf::foo_d8' => {
desc => 'foo=%8d',
setup => 'my $s; my $a1 = 1234;',
code => '$s = sprintf "foo=%8d", $a1',
},
'func::sprintf::f0' => {
# "%.0f" is very special-cased
desc => 'sprintf "%.0f"',
setup => 'my $s; my $a1 = 123.456;',
code => '$s = sprintf "%.0f", $a1',
},
'func::sprintf::foo_f0' => {
# "...%.0f..." is special-cased
desc => 'sprintf "foo=%.0f"',
setup => 'my $s; my $a1 = 123.456;',
code => '$s = sprintf "foo=%.0f\n", $a1',
},
'func::sprintf::foo_f93' => {
desc => 'foo=%9.3f',
setup => 'my $s; my $a1 = 123.456;',
code => '$s = sprintf "foo=%9.3f\n", $a1',
},
'func::sprintf::g9' => {
# "...%.NNNg..." is special-cased
desc => '%.9g',
setup => 'my $s; my $a1 = 123.456;',
code => '$s = sprintf "%.9g", $a1',
},
'func::sprintf::foo_g9' => {
# "...%.NNNg..." is special-cased
desc => 'foo=%.9g',
setup => 'my $s; my $a1 = 123.456;',
code => '$s = sprintf "foo=%.9g\n", $a1',
},
'func::sprintf::foo_g93' => {
desc => 'foo=%9.3g',
setup => 'my $s; my $a1 = 123.456;',
code => '$s = sprintf "foo=%9.3g\n", $a1',
},
'func::sprintf::s' => {
desc => '%s',
setup => 'my $s; my $a1 = "abcd";',
code => '$s = sprintf "%s", $a1',
},
'func::sprintf::foo_s' => {
desc => 'foo=%s',
setup => 'my $s; my $a1 = "abcd";',
code => '$s = sprintf "foo=%s", $a1',
},
'func::sprintf::mixed_utf8_sss' => {
desc => 'foo=%s bar=%s baz=%s',
setup => 'my $s;my $a = "ab\x{100}cd"; my $b = "efg"; my $c = "h\x{101}ij"',
code => '$s = sprintf "foo=%s bar=%s baz=%s", $a, $b, $c',
},
# sprint that's likely to be optimised to an OP_MULTICONCAT
'func::sprintf::l' => {
setup => 'my $lex1 = "abcd"',
code => 'sprintf "%s", $lex1',
},
'func::sprintf::g_l' => {
setup => 'our $pkg; my $lex1 = "abcd"',
code => '$pkg = sprintf "%s", $lex1',
},
'func::sprintf::g_append_l' => {
setup => 'our $pkg; my $lex1 = "abcd"',
pre => '$pkg = "pqrs"',
code => '$pkg .= sprintf "%s", $lex1',
},
'func::sprintf::g_ll' => {
setup => 'our $pkg; my $lex1 = "abcd"; my $lex2 = "wxyz"',
code => '$pkg = sprintf "%s%s", $lex1, $lex2',
},
'func::sprintf::g_append_ll' => {
setup => 'our $pkg; my $lex1 = "abcd"; my $lex2 = "wxyz"',
pre => '$pkg = "pqrs"',
code => '$pkg .= sprintf "%s%s", $lex1, $lex2',
},
'func::sprintf::g_cl' => {
setup => 'our $pkg; my $lex1 = "abcd"',
code => '$pkg = sprintf "foo=%s", $lex1',
},
'func::sprintf::g_clclc' => {
setup => 'our $pkg; my $lex1 = "abcd"; my $lex2 = "wxyz"',
code => '$pkg = sprintf "foo=%s bar=%s\n", $lex1, $lex2',
},
'func::sprintf::l_l' => {
setup => 'my $lex; my $lex1 = "abcd"',
code => '$lex = sprintf "%s", $lex1',
},
'func::sprintf::l_append_l' => {
setup => 'my $lex; my $lex1 = "abcd"',
pre => '$lex = "pqrs"',
code => '$lex .= sprintf "%s", $lex1',
},
'func::sprintf::ll' => {
setup => 'my $lex1 = "abcd"; my $lex2 = "wxyz"',
code => 'sprintf "%s%s", $lex1, $lex2',
},
'func::sprintf::l_ll' => {
setup => 'my $lex; my $lex1 = "abcd"; my $lex2 = "wxyz"',
code => '$lex = sprintf "%s%s", $lex1, $lex2',
},
'func::sprintf::l_append_ll' => {
setup => 'my $lex; my $lex1 = "abcd"; my $lex2 = "wxyz"',
pre => '$lex = "pqrs"',
code => '$lex .= sprintf "%s%s", $lex1, $lex2',
},
'func::sprintf::l_cl' => {
setup => 'my $lex; my $lex1 = "abcd"',
code => '$lex = sprintf "foo=%s", $lex1',
},
'func::sprintf::l_clclc' => {
setup => 'my $lex; my $lex1 = "abcd"; my $lex2 = "wxyz"',
code => '$lex = sprintf "foo=%s bar=%s\n", $lex1, $lex2',
},
'func::sprintf::m_l' => {
setup => 'my $lex1 = "abcd"',
code => 'my $lex = sprintf "%s", $lex1',
},
'func::sprintf::m_ll' => {
setup => 'my $lex1 = "abcd"; my $lex2 = "wxyz"',
code => 'my $lex = sprintf "%s%s", $lex1, $lex2',
},
'func::sprintf::m_cl' => {
setup => 'my $lex1 = "abcd"',
code => 'my $lex = sprintf "foo=%s", $lex1',
},
'func::sprintf::m_clclc' => {
setup => 'my $lex1 = "abcd"; my $lex2 = "wxyz"',
code => 'my $lex = sprintf "foo=%s bar=%s\n", $lex1, $lex2',
},
'func::sprintf::utf8__l_lll' => {
desc => '$s = sprintf("foo=%s bar=%s baz=%s", $a, $b, $c) where $a,$c are utf8',
setup => 'my $s; my $a = "ab\x{100}cde"; my $b = "fghij"; my $c = "\x{101}klmn"',
code => '$s = sprintf "foo=%s bar=%s baz=%s", $a, $b, $c',
},
# S///
'func::subst::bool' => {
desc => 's/// in boolean context',
setup => '',
code => '$_ = "aaa"; !s/./x/g;'
},
'func::values::scalar_cxt_empty' => {
desc => ' values() on an empty hash in scalar context',
setup => 'my $k; my %h = ()',
code => '$k = values %h',
},
'func::values::scalar_cxt' => {
desc => ' values() on a non-empty hash in scalar context',
setup => 'my $k; my %h = qw(aardvark 1 banana 2 cucumber 3)',
code => '$k = values %h',
},
'func::values::list_cxt_empty' => {
desc => ' values() on an empty hash in list context',
setup => 'my %h = ()',
code => '() = values %h',
},
'func::values::list_cxt' => {
desc => ' values() on a non-empty hash in list context',
setup => 'my %h = qw(aardvark 1 banana 2 cucumber 3)',
code => '() = values %h',
},
'loop::block' => {
desc => 'empty basic loop',
setup => '',
code => '{1;}',
},
'loop::do' => {
desc => 'basic do block',
setup => 'my $x; my $y = 2;',
code => '$x = do {1; $y}', # the ';' stops the do being optimised
},
'loop::for::my_range1' => {
desc => 'empty for loop with my var and 1 integer range',
setup => '',
code => 'for my $x (1..1) {}',
},
'loop::for::lex_range1' => {
desc => 'empty for loop with lexical var and 1 integer range',
setup => 'my $x;',
code => 'for $x (1..1) {}',
},
'loop::for::pkg_range1' => {
desc => 'empty for loop with package var and 1 integer range',
setup => '$x = 1;',
code => 'for $x (1..1) {}',
},
'loop::for::defsv_range1' => {
desc => 'empty for loop with $_ and integer 1 range',
setup => ';',
code => 'for (1..1) {}',
},
'loop::for::my_range4' => {
desc => 'empty for loop with my var and 4 integer range',
setup => '',
code => 'for my $x (1..4) {}',
},
'loop::for::lex_range4' => {
desc => 'empty for loop with lexical var and 4 integer range',
setup => 'my $x;',
code => 'for $x (1..4) {}',
},
'loop::for::pkg_range4' => {
desc => 'empty for loop with package var and 4 integer range',
setup => '$x = 1;',
code => 'for $x (1..4) {}',
},
'loop::for::defsv_range4' => {
desc => 'empty for loop with $_ and integer 4 range',
setup => ';',
code => 'for (1..4) {}',
},
'loop::for::my_list1' => {
desc => 'empty for loop with my var and 1 integer list',
setup => '',
code => 'for my $x (1) {}',
},
'loop::for::lex_list1' => {
desc => 'empty for loop with lexical var and 1 integer list',
setup => 'my $x;',
code => 'for $x (1) {}',
},
'loop::for::pkg_list1' => {
desc => 'empty for loop with package var and 1 integer list',
setup => '$x = 1;',
code => 'for $x (1) {}',
},
'loop::for::defsv_list1' => {
desc => 'empty for loop with $_ and integer 1 list',
setup => ';',
code => 'for (1) {}',
},
'loop::for::my_list4' => {
desc => 'empty for loop with my var and 4 integer list',
setup => '',
code => 'for my $x (1,2,3,4) {}',
},
'loop::for::lex_list4' => {
desc => 'empty for loop with lexical var and 4 integer list',
setup => 'my $x;',
code => 'for $x (1,2,3,4) {}',
},
'loop::for::pkg_list4' => {
desc => 'empty for loop with package var and 4 integer list',
setup => '$x = 1;',
code => 'for $x (1,2,3,4) {}',
},
'loop::for::defsv_list4' => {
desc => 'empty for loop with $_ and integer 4 list',
setup => '',
code => 'for (1,2,3,4) {}',
},
'loop::for::my_array1' => {
desc => 'empty for loop with my var and 1 integer array',
setup => 'my @a = (1);',
code => 'for my $x (@a) {}',
},
'loop::for::lex_array1' => {
desc => 'empty for loop with lexical var and 1 integer array',
setup => 'my $x; my @a = (1);',
code => 'for $x (@a) {}',
},
'loop::for::pkg_array1' => {
desc => 'empty for loop with package var and 1 integer array',
setup => '$x = 1; my @a = (1);',
code => 'for $x (@a) {}',
},
'loop::for::defsv_array1' => {
desc => 'empty for loop with $_ and integer 1 array',
setup => 'my @a = (@a);',
code => 'for (1) {}',
},
'loop::for::my_array4' => {
desc => 'empty for loop with my var and 4 integer array',
setup => 'my @a = (1..4);',
code => 'for my $x (@a) {}',
},
'loop::for::lex_array4' => {
desc => 'empty for loop with lexical var and 4 integer array',
setup => 'my $x; my @a = (1..4);',
code => 'for $x (@a) {}',
},
'loop::for::pkg_array4' => {
desc => 'empty for loop with package var and 4 integer array',
setup => '$x = 1; my @a = (1..4);',
code => 'for $x (@a) {}',
},
'loop::for::defsv_array4' => {
desc => 'empty for loop with $_ and integer 4 array',
setup => 'my @a = (1..4);',
code => 'for (@a) {}',
},
'loop::for::next4' => {
desc => 'for loop containing only next with my var and integer 4 array',
setup => 'my @a = (1..4);',
code => 'for my $x (@a) {next}',
},
'loop::grep::expr_3int' => {
desc => 'grep $_ > 0, 1,2,3',
setup => 'my @a',
code => '@a = grep $_ > 0, 1,2,3',
},
'loop::grep::block_3int' => {
desc => 'grep { 1; $_ > 0} 1,2,3',
setup => 'my @a',
code => '@a = grep { 1; $_ > 0} 1,2,3',
},
'loop::map::expr_3int' => {
desc => 'map $_+1, 1,2,3',
setup => 'my @a',
code => '@a = map $_+1, 1,2,3',
},
'loop::map::block_3int' => {
desc => 'map { 1; $_+1} 1,2,3',
setup => 'my @a',
code => '@a = map { 1; $_+1} 1,2,3',
},
'loop::while::i1' => {
desc => 'empty while loop 1 iteration',
setup => 'my $i = 0;',
code => 'while (++$i % 2) {}',
},
'loop::while::i4' => {
desc => 'empty while loop 4 iterations',
setup => 'my $i = 0;',
code => 'while (++$i % 4) {}',
},
'regex::anyof_plus::anchored' => {
setup => '$_ = "a" x 100;',
code => '/^[acgt]+/',
},
'regex::anyof_plus::floating' => {
desc => '/[acgt]+where match starts at position 0 for 100 chars/',
setup => '$_ = "a" x 100;',
code => '/[acgt]+/',
},
'regex::anyof_plus::floating_away' => {
desc => '/[acgt]+/ where match starts at position 100 for 100 chars',
setup => '$_ = ("0" x 100) . ("a" x 100);',
code => '/[acgt]+/',
},
'regex::whilem::min_captures_fail' => {
desc => '/WHILEM with anon-greedy match and captures that fails',
setup => '$_ = ("a" x 20)',
code => '/^(?:(.)(.))*?[XY]/',
},
'regex::whilem::max_captures_fail' => {
desc => '/WHILEM with a greedy match and captures that fails',
setup => '$_ = ("a" x 20)',
code => '/^(?:(.)(.))*[XY]/',
},
];
|