1# mode: run 2# tag: closures 3# preparse: id 4# preparse: def_to_cdef 5# 6# closure_tests_3.pyx 7# 8# Battery of tests for closures in Cython. Based on the collection of 9# compiler tests from P423/B629 at Indiana University, Spring 1999 and 10# Fall 2000. Special thanks to R. Kent Dybvig, Dan Friedman, Kevin 11# Millikin, and everyone else who helped to generate the original 12# tests. Converted into a collection of Python/Cython tests by Craig 13# Citro. 14# 15# Note: This set of tests is split (somewhat randomly) into several 16# files, simply because putting all the tests in a single file causes 17# gcc and g++ to buckle under the load. 18# 19 20 21def g1649(): 22 """ 23 >>> g1649() 24 6 25 """ 26 def g1648(): 27 def g1647(x_1211): 28 return x_1211 29 return g1647 30 f_1212 = g1648() 31 if (f_1212(True)): 32 f_1212(3) 33 f_1212(4) 34 else: 35 f_1212(5) 36 return f_1212(6) 37 38 39def g1653(): 40 """ 41 >>> g1653() 42 5 43 """ 44 def g1652(): 45 def g1651(x_1213): 46 return (x_1213+1) 47 return g1651 48 f_1214 = g1652() 49 def g1650(): 50 f_1215 = 3 51 return (f_1215)+(1) 52 return f_1214(g1650()) 53 54 55def g1662(): 56 """ 57 >>> g1662() 58 51 59 """ 60 x_1223 = 15 61 def g1661(): 62 def g1660(h_1219, v_1218): 63 return (h_1219)*(v_1218) 64 return g1660 65 f_1222 = g1661() 66 def g1659(): 67 def g1658(x_1217): 68 return (x_1217)+(5) 69 return g1658 70 k_1221 = g1659() 71 def g1657(): 72 def g1656(x_1216): 73 return (x_1216+1) 74 return g1656 75 g_1220 = g1657() 76 def g1655(): 77 def g1654(): 78 g_1224 = 3 79 return f_1222(g_1224, x_1223) 80 return g_1220(g1654()) 81 return k_1221(g1655()) 82 83 84def g1665(): 85 """ 86 >>> g1665() 87 5 88 """ 89 x_1225 = 4 90 def g1664(): 91 def g1663(): 92 return x_1225 93 return g1663 94 f_1226 = g1664() 95 x_1225 = 5 96 return f_1226() 97 98 99def g1670(): 100 """ 101 >>> g1670() 102 5 103 """ 104 def g1669(): 105 def g1668(): 106 def g1667(): 107 def g1666(): 108 return 4 109 return g1666 110 y_1227 = g1667() 111 return y_1227() 112 return (g1668()+1) 113 x_1228 = g1669() 114 return x_1228 115 116 117def g1674(): 118 """ 119 >>> g1674() 120 1 121 """ 122 def g1673(): 123 def g1671(n_1230): 124 def g1672(): 125 return n_1230 == 0 126 if (g1672()): 127 return 1 128 else: 129 return one_1229((n_1230-1)) 130 return g1671 131 one_1229 = g1673() 132 return one_1229(13) 133 134 135def g1681(): 136 """ 137 >>> g1681() 138 True 139 """ 140 def g1680(): 141 def g1678(x_1234): 142 def g1679(): 143 return x_1234 == 0 144 if (g1679()): 145 return True 146 else: 147 return odd_1231((x_1234-1)) 148 return g1678 149 even_1232 = g1680() 150 def g1677(): 151 def g1675(x_1233): 152 def g1676(): 153 return x_1233 == 0 154 if (g1676()): 155 return False 156 else: 157 return even_1232((x_1233-1)) 158 return g1675 159 odd_1231 = g1677() 160 return odd_1231(13) 161 162 163def g1688(): 164 """ 165 >>> g1688() 166 True 167 """ 168 t_1236 = True 169 f_1235 = False 170 def g1687(): 171 def g1685(x_1240): 172 def g1686(): 173 return x_1240 == 0 174 if (g1686()): 175 return t_1236 176 else: 177 return odd_1237((x_1240-1)) 178 return g1685 179 even_1238 = g1687() 180 def g1684(): 181 def g1682(x_1239): 182 def g1683(): 183 return x_1239 == 0 184 if (g1683()): 185 return f_1235 186 else: 187 return even_1238((x_1239-1)) 188 return g1682 189 odd_1237 = g1684() 190 return odd_1237(13) 191 192 193def g1698(): 194 """ 195 >>> g1698() 196 True 197 """ 198 def g1697(): 199 def g1696(x_1241): 200 return x_1241 201 return g1696 202 even_1242 = g1697() 203 def g1695(): 204 def g1694(): 205 def g1692(x_1246): 206 def g1693(): 207 return x_1246 == 0 208 if (g1693()): 209 return True 210 else: 211 return odd_1243((x_1246-1)) 212 return g1692 213 even_1244 = g1694() 214 def g1691(): 215 def g1689(x_1245): 216 def g1690(): 217 return x_1245 == 0 218 if (g1690()): 219 return False 220 else: 221 return even_1244((x_1245-1)) 222 return g1689 223 odd_1243 = g1691() 224 return odd_1243(13) 225 return even_1242(g1695()) 226 227 228def g1702(): 229 """ 230 >>> g1702() 231 120 232 """ 233 def g1701(): 234 def g1699(n_1248): 235 def g1700(): 236 return n_1248 == 0 237 if (g1700()): 238 return 1 239 else: 240 return (n_1248)*(fact_1247((n_1248-1))) 241 return g1699 242 fact_1247 = g1701() 243 return fact_1247(5) 244 245 246def g1716(): 247 """ 248 >>> g1716() 249 10 250 """ 251 x_1249 = 5 252 def g1715(): 253 def g1713(u_1263, v_1262, w_1261): 254 def g1714(): 255 return u_1263 == 0 256 if (g1714()): 257 return b_1251(v_1262, w_1261) 258 else: 259 return a_1252((u_1263)-(1), v_1262, w_1261) 260 return g1713 261 a_1252 = g1715() 262 def g1712(): 263 def g1705(q_1255, r_1254): 264 p_1256 = (q_1255)*(r_1254) 265 def g1711(): 266 def g1709(n_1260): 267 def g1710(): 268 return n_1260 == 0 269 if (g1710()): 270 return c_1250(p_1256) 271 else: 272 return o_1257((n_1260)-(1)) 273 return g1709 274 e_1258 = g1711() 275 def g1708(): 276 def g1706(n_1259): 277 def g1707(): 278 return n_1259 == 0 279 if (g1707()): 280 return c_1250(x_1249) 281 else: 282 return e_1258((n_1259)-(1)) 283 return g1706 284 o_1257 = g1708() 285 return e_1258((q_1255)*(r_1254)) 286 return g1705 287 b_1251 = g1712() 288 def g1704(): 289 def g1703(x_1253): 290 return (5)*(x_1253) 291 return g1703 292 c_1250 = g1704() 293 return a_1252(3, 2, 1) 294 295 296def g1729(): 297 """ 298 >>> g1729() 299 537516 300 """ 301 def g1728(): 302 def g1727(x_1269): 303 return (x_1269+1) 304 return g1727 305 f_1276 = g1728() 306 def g1726(): 307 def g1725(x_1268): 308 return (x_1268-1) 309 return g1725 310 g_1275 = g1726() 311 def g1724(): 312 def g1723(x_1267): 313 return (x_1267+1) 314 return g1723 315 t_1274 = g1724() 316 def g1722(): 317 def g1721(x_1266): 318 return (x_1266+1) 319 return g1721 320 j_1273 = g1722() 321 def g1720(): 322 def g1719(x_1265): 323 return (x_1265+1) 324 return g1719 325 i_1272 = g1720() 326 def g1718(): 327 def g1717(x_1264): 328 return (x_1264+1) 329 return g1717 330 h_1271 = g1718() 331 x_1270 = 80 332 a_1279 = f_1276(x_1270) 333 b_1278 = g_1275(x_1270) 334 c_1277 = h_1271(i_1272(j_1273(t_1274(x_1270)))) 335 return (a_1279)*((b_1278)*((c_1277)+(0))) 336 337 338def g1733(): 339 """ 340 >>> g1733() 341 120 342 """ 343 def g1732(): 344 def g1730(fact_1281, n_1280): 345 def g1731(): 346 return n_1280 == 0 347 if (g1731()): 348 return 1 349 else: 350 return (fact_1281(fact_1281, (n_1280-1)))*(n_1280) 351 return g1730 352 fact_1282 = g1732() 353 return fact_1282(fact_1282, 5) 354 355 356def g1737(): 357 """ 358 >>> g1737() 359 10000 360 """ 361 def g1736(): 362 def g1735(x_1283): 363 return (x_1283)+(1000) 364 return g1735 365 f_1284 = g1736() 366 def g1734(): 367 return f_1284(-2) == 0 368 if (g1734()): 369 return f_1284(6000) 370 else: 371 return f_1284(f_1284(8000)) 372 373 374def g1741(): 375 """ 376 >>> g1741() 377 10000 378 """ 379 def g1740(): 380 def g1739(x_1285): 381 return (x_1285)+(1000) 382 return g1739 383 f_1286 = g1740() 384 def g1738(): 385 return f_1286(-1) == 0 386 if (g1738()): 387 return f_1286(6000) 388 else: 389 return f_1286(f_1286(8000)) 390 391 392def g1747(): 393 """ 394 >>> g1747() 395 8000 396 """ 397 def g1746(): 398 def g1745(x_1288, y_1287): 399 return (x_1288)+(1000) 400 return g1745 401 f_1289 = g1746() 402 def g1744(): 403 def g1743(): 404 def g1742(): 405 return 0 406 return f_1289(3000, g1742()) 407 if (g1743()): 408 return f_1289(f_1289(4000, 0), 0) 409 else: 410 return 8000 411 return (g1744())+(2000) 412 413 414def g1754(): 415 """ 416 >>> g1754() 417 24 418 """ 419 def g1753(): 420 def g1752(): 421 def g1751(): 422 def g1748(x_1290): 423 def g1749(y_1291): 424 def g1750(z_1292): 425 return (x_1290)+((y_1291)+((z_1292)+(y_1291))) 426 return g1750 427 return g1749 428 return g1748 429 return g1751()(5) 430 return g1752()(6) 431 return g1753()(7) 432 433 434def g1765(): 435 """ 436 >>> g1765() 437 35 438 """ 439 def g1764(): 440 def g1763(): 441 def g1762(): 442 def g1761(): 443 def g1760(): 444 def g1755(x_1293): 445 def g1756(y_1294): 446 def g1757(z_1295): 447 def g1758(w_1296): 448 def g1759(u_1297): 449 return (x_1293)+((y_1294)+((z_1295)+((w_1296)+(u_1297)))) 450 return g1759 451 return g1758 452 return g1757 453 return g1756 454 return g1755 455 return g1760()(5) 456 return g1761()(6) 457 return g1762()(7) 458 return g1763()(8) 459 return g1764()(9) 460 461 462def g1769(): 463 """ 464 >>> g1769() 465 True 466 """ 467 def g1768(): 468 def g1767(x_1298): 469 return x_1298 470 return g1767 471 f_1299 = g1768() 472 def g1766(): 473 return hasattr(f_1299, '__call__') 474 if (g1766()): 475 return True 476 else: 477 return False 478 479 480def g1779(): 481 """ 482 >>> g1779() 483 6 484 """ 485 def g1778(): 486 def g1773(sum_1301, ls_1300): 487 def g1777(): 488 return (ls_1300 == []) 489 if (g1777()): 490 return 0 491 else: 492 def g1776(): 493 return (ls_1300[0]) 494 def g1775(): 495 def g1774(): 496 return (ls_1300[1]) 497 return sum_1301(sum_1301, g1774()) 498 return (g1776())+(g1775()) 499 return g1773 500 sum_1302 = g1778() 501 def g1772(): 502 def g1771(): 503 def g1770(): 504 return [3,[]] 505 return [2,g1770()] 506 return [1,g1771()] 507 return sum_1302(sum_1302, g1772()) 508 509 510def g1785(): 511 """ 512 >>> g1785() 513 1500 514 """ 515 def g1784(): 516 def g1783(): 517 def g1780(a_1303): 518 def g1781(): 519 def g1782(): 520 if (True): 521 return 200 522 (a_1303)+(g1782()) 523 return 1500 524 return g1781 525 return g1780 526 return g1783()(1000) 527 return g1784()() 528 529 530def g1791(): 531 """ 532 >>> g1791() 533 102 534 """ 535 def g1790(): 536 def g1789(): 537 def g1786(b_1304): 538 def g1787(a_1305): 539 def g1788(): 540 if (1): 541 return 2 542 a_1305 = g1788() 543 return (a_1305)+(b_1304) 544 return g1787 545 return g1786 546 return g1789()(100) 547 return g1790()(200) 548 549 550def g1800(): 551 """ 552 >>> g1800() 553 2600 554 """ 555 def g1799(): 556 def g1798(): 557 def g1797(): 558 def g1792(a_1306): 559 def g1793(b_1307): 560 def g1794(): 561 if (b_1307): 562 return 200 563 a_1306 = g1794() 564 def g1795(c_1308): 565 def g1796(): 566 if (300): 567 return 400 568 c_1308 = g1796() 569 return (a_1306)+((b_1307)+(c_1308)) 570 return g1795 571 return g1793 572 return g1792 573 return g1797()(1000) 574 return g1798()(2000) 575 return g1799()(3000) 576 577 578def g1807(): 579 """ 580 >>> g1807() 581 3628800 582 """ 583 def g1806(): 584 def g1804(x_1310): 585 def g1805(): 586 return x_1310 == 0 587 if (g1805()): 588 return 1 589 else: 590 return (x_1310)*(f_1309((x_1310)-(1))) 591 return g1804 592 f_1309 = g1806() 593 def g1803(): 594 def g1801(a_1311): 595 def g1802(b_1312): 596 return a_1311(b_1312) 597 return g1802 598 return g1801 599 g_1313 = g1803() 600 return g_1313(f_1309)(10) 601 602 603def g1828(): 604 """ 605 >>> g1828() 606 [52, [44, [17, [44, [52, 17]]]]] 607 """ 608 def g1827(): 609 def g1826(): 610 return (a_1316)+(b_1315) 611 return g1826 612 f_1318 = g1827() 613 def g1825(): 614 def g1822(y_1320): 615 def g1824(): 616 def g1823(y_1321): 617 return y_1321 618 return g1823 619 g_1317 = g1824() 620 return (y_1320)+(y_1320) 621 return g1822 622 g_1317 = g1825() 623 a_1316 = 17 624 b_1315 = 35 625 def g1821(): 626 def g1820(): 627 def g1819(): 628 return a_1316 629 return g1819 630 def g1818(): 631 def g1817(v_1319): 632 a_1316 = v_1319 633 return g1817 634 return [g1820(),g1818()] 635 h_1314 = g1821() 636 x1_1324 = f_1318() 637 x2_1323 = g_1317(22) 638 def g1816(): 639 def g1815(): 640 return (h_1314[0]) 641 return g1815()() 642 x3_1322 = g1816() 643 x4_1325 = g_1317(22) 644 def g1814(): 645 return (h_1314[1]) 646 g1814()(3) 647 x5_1327 = f_1318() 648 def g1813(): 649 def g1812(): 650 return (h_1314[0]) 651 return g1812()() 652 x6_1326 = g1813() 653 def g1811(): 654 def g1810(): 655 def g1809(): 656 def g1808(): 657 return [x5_1327,x6_1326] 658 return [x4_1325,g1808()] 659 return [x3_1322,g1809()] 660 return [x2_1323,g1810()] 661 return [x1_1324,g1811()] 662 663 664def g1843(): 665 """ 666 >>> g1843() 667 [52, [17, [35, [17, 35]]]] 668 """ 669 def g1842(): 670 def g1841(): 671 return (a_1330)+(b_1329) 672 return g1841 673 f_1331 = g1842() 674 a_1330 = 17 675 b_1329 = 35 676 def g1840(): 677 def g1839(): 678 def g1838(): 679 return a_1330 680 return g1838 681 def g1837(): 682 def g1836(): 683 return b_1329 684 return g1836 685 return [g1839(),g1837()] 686 h_1328 = g1840() 687 def g1835(): 688 def g1834(): 689 def g1833(): 690 def g1832(): 691 def g1831(): 692 return (h_1328[0]) 693 return g1831()() 694 def g1830(): 695 def g1829(): 696 return (h_1328[1]) 697 return g1829()() 698 return [g1832(),g1830()] 699 return [b_1329,g1833()] 700 return [a_1330,g1834()] 701 return [f_1331(),g1835()] 702 703