Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
539d795c
Commit
539d795c
authored
Feb 01, 2010
by
Craig Citro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a bunch of new tests for closures.
parent
da4566a3
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
3003 additions
and
0 deletions
+3003
-0
tests/run/closure_tests_1.pyx
tests/run/closure_tests_1.pyx
+401
-0
tests/run/closure_tests_2.pyx
tests/run/closure_tests_2.pyx
+498
-0
tests/run/closure_tests_3.pyx
tests/run/closure_tests_3.pyx
+698
-0
tests/run/closure_tests_4.pyx
tests/run/closure_tests_4.pyx
+829
-0
tests/run/lambda_tests.pyx
tests/run/lambda_tests.pyx
+577
-0
No files found.
tests/run/closure_tests_1.pyx
0 → 100644
View file @
539d795c
#
# closure_tests_1.pyx
#
# Battery of tests for closures in Cython. Based on the collection of
# compiler tests from P423/B629 at Indiana University, Spring 1999 and
# Fall 2000. Special thanks to R. Kent Dybvig, Dan Friedman, Kevin
# Millikin, and everyone else who helped to generate the original
# tests. Converted into a collection of Python/Cython tests by Craig
# Citro.
#
# Note: This set of tests is split (somewhat randomly) into several
# files, simply because putting all the tests in a single file causes
# gcc and g++ to buckle under the load.
#
def
g1425
():
"""
>>> g1425()
142
"""
if
(
True
):
def
g1424
():
if
(
True
):
return
122
return
(
20
)
+
(
g1424
())
else
:
return
10000
def
g1432
():
"""
>>> g1432()
[0, []]
"""
def
g1431
():
return
[
0
,[]]
x_1056
=
g1431
()
if
(
x_1056
):
def
g1430
():
def
g1429
():
return
(
x_1056
[
0
])
def
g1428
():
return
(
x_1056
[
0
])
return
(
g1429
())
+
(
g1428
())
x_1056
[
0
]
=
g1430
()
return
x_1056
def
g1435
():
"""
>>> g1435()
4000
"""
def
g1434
():
def
g1433
(
y_1057
):
return
y_1057
return
g1433
return
g1434
()(
4000
)
def
g1438
():
"""
>>> g1438()
1
"""
def
g1437
():
def
g1436
(
x_1058
):
return
x_1058
return
g1436
f_1059
=
g1437
()
return
(
f_1059
(
0
)
+
1
)
def
g1441
():
"""
>>> g1441()
4
"""
def
g1440
():
def
g1439
(
y_1060
):
return
y_1060
return
g1439
f_1061
=
g1440
()
return
f_1061
(
f_1061
(
4
))
def
g1446
():
"""
>>> g1446()
4
"""
def
g1445
():
def
g1444
(
f_1063
):
return
f_1063
(
f_1063
(
4
))
return
g1444
def
g1443
():
def
g1442
(
y_1062
):
return
y_1062
return
g1442
return
g1445
()(
g1443
())
def
g1449
():
"""
>>> g1449()
9000
"""
def
g1448
():
a_1064
=
4000
def
g1447
(
b_1065
):
return
(
a_1064
)
+
(
b_1065
)
return
g1447
return
g1448
()(
5000
)
def
g1454
():
"""
>>> g1454()
9000
"""
def
g1453
():
def
g1452
():
def
g1450
(
a_1066
):
def
g1451
(
b_1067
):
return
(
a_1066
)
+
(
b_1067
)
return
g1451
return
g1450
return
g1452
()(
4000
)
return
g1453
()(
5000
)
def
g1459
():
"""
>>> g1459()
2
"""
def
g1458
():
def
g1457
(
f_1069
):
return
f_1069
(
f_1069
(
0
))
return
g1457
def
g1456
():
def
g1455
(
x_1068
):
return
(
x_1068
+
1
)
return
g1455
return
g1458
()(
g1456
())
def
g1462
():
"""
>>> g1462()
0
"""
x_1072
=
0
def
g1461
():
def
g1460
(
x_1070
):
return
x_1070
return
g1460
f_1071
=
g1461
()
a_1075
=
f_1071
(
x_1072
)
b_1074
=
f_1071
(
x_1072
)
c_1073
=
f_1071
(
x_1072
)
return
((
a_1075
)
+
(
b_1074
))
+
(
c_1073
)
def
g1465
():
"""
>>> g1465()
3
"""
x_1080
=
0
y_1079
=
1
z_1078
=
2
def
g1464
():
def
g1463
(
x_1076
):
return
x_1076
return
g1463
f_1077
=
g1464
()
a_1083
=
f_1077
(
x_1080
)
b_1082
=
f_1077
(
y_1079
)
c_1081
=
f_1077
(
z_1078
)
return
((
a_1083
)
+
(
b_1082
))
+
(
c_1081
)
def
g1468
():
"""
>>> g1468()
0
"""
def
g1467
():
def
g1466
(
x_1085
,
y_1084
):
return
x_1085
return
g1466
f_1086
=
g1467
()
a_1087
=
f_1086
(
0
,
1
)
return
f_1086
(
a_1087
,
a_1087
)
def
g1471
():
"""
>>> g1471()
0
"""
x_1094
=
0
y_1093
=
1
z_1092
=
2
def
g1470
():
def
g1469
(
x_1090
,
y_1089
,
z_1088
):
return
x_1090
return
g1469
f_1091
=
g1470
()
a_1097
=
f_1091
(
x_1094
,
y_1093
,
z_1092
)
b_1096
=
y_1093
c_1095
=
z_1092
return
f_1091
(
a_1097
,
b_1096
,
c_1095
)
def
g1474
():
"""
>>> g1474()
3
"""
def
g1473
():
def
g1472
(
a_1101
,
b_1100
,
c_1099
,
d_1098
):
return
(
a_1101
)
+
(
d_1098
)
return
g1472
f_1102
=
g1473
()
return
f_1102
(
0
,
1
,
2
,
3
)
def
g1478
():
"""
>>> g1478()
3
"""
def
g1477
():
def
g1476
(
x_1103
):
return
x_1103
return
g1476
f_1104
=
g1477
()
def
g1475
():
a_1107
=
0
b_1106
=
1
c_1105
=
2
return
(
f_1104
(
a_1107
))
+
((
f_1104
(
b_1106
))
+
(
f_1104
(
c_1105
)))
return
(
f_1104
(
0
))
+
(
g1475
())
def
g1483
():
"""
>>> g1483()
"""
a_1108
=
0
def
g1482
():
def
g1481
():
return
0
return
g1481
a_1110
=
g1482
()
def
g1480
():
def
g1479
():
return
11
return
g1479
b_1109
=
g1480
()
a_1110
=
11
def
g1486
():
"""
>>> g1486()
"""
a_1111
=
0
def
g1485
():
def
g1484
():
a_1113
=
0
return
g1484
a_1113
=
g1485
()
b_1112
=
11
return
a_1113
()
def
g1491
():
"""
>>> g1491()
0
"""
def
g1490
():
def
g1489
():
return
0
return
g1489
a_1115
=
g1490
()
def
g1488
():
def
g1487
():
return
11
return
g1487
b_1114
=
g1488
()
return
a_1115
()
def
g1494
():
"""
>>> g1494()
2
"""
def
g1493
():
x_1116
=
1
def
g1492
(
y_1117
):
return
(
x_1116
)
+
(
y_1117
)
return
g1492
f_1118
=
g1493
()
x_1119
=
0
return
f_1118
(
f_1118
(
x_1119
))
def
g1501
():
"""
>>> g1501()
3050
"""
def
g1500
():
def
g1499
():
def
g1498
(
x_1121
):
return
(
x_1121
)
+
(
50
)
return
g1498
t_1122
=
g1499
()
def
g1497
(
f_1123
):
return
t_1122
(
f_1123
(
1000
))
return
g1497
def
g1496
():
def
g1495
(
y_1120
):
return
(
y_1120
)
+
(
2000
)
return
g1495
return
g1500
()(
g1496
())
def
g1508
():
"""
>>> g1508()
60
"""
def
g1507
():
def
g1506
():
def
g1505
():
def
g1502
(
a_1124
):
def
g1503
(
b_1125
):
def
g1504
(
c_1126
):
return
(
a_1124
)
+
((
b_1125
)
+
(
c_1126
))
return
g1504
return
g1503
return
g1502
return
g1505
()(
10
)
return
g1506
()(
20
)
return
g1507
()(
30
)
def
g1513
():
"""
>>> g1513()
5
"""
def
g1512
():
def
g1509
(
b_1127
):
def
g1511
():
def
g1510
(
a_1128
):
return
(
b_1127
)
+
(
a_1128
)
return
g1510
return
g1511
()(
2
)
return
g1509
return
g1512
()(
3
)
def
g1518
():
"""
>>> g1518()
5
"""
def
g1517
():
def
g1516
(
f_1130
):
return
f_1130
(
f_1130
(
5
))
return
g1516
def
g1515
():
def
g1514
(
x_1129
):
return
x_1129
return
g1514
return
g1517
()(
g1515
())
def
g1523
():
"""
>>> g1523()
8000
"""
def
g1522
():
def
g1521
():
def
g1520
(
x_1131
):
return
(
x_1131
)
+
(
3000
)
return
g1520
f_1132
=
g1521
()
def
g1519
(
y_1133
):
return
f_1132
(
f_1132
(
y_1133
))
return
g1519
return
g1522
()(
2000
)
tests/run/closure_tests_2.pyx
0 → 100644
View file @
539d795c
#
# closure_tests_2.pyx
#
# Battery of tests for closures in Cython. Based on the collection of
# compiler tests from P423/B629 at Indiana University, Spring 1999 and
# Fall 2000. Special thanks to R. Kent Dybvig, Dan Friedman, Kevin
# Millikin, and everyone else who helped to generate the original
# tests. Converted into a collection of Python/Cython tests by Craig
# Citro.
#
# Note: This set of tests is split (somewhat randomly) into several
# files, simply because putting all the tests in a single file causes
# gcc and g++ to buckle under the load.
#
def
g1526
():
"""
>>> g1526()
2
"""
x_1134
=
0
def
g1525
():
x_1136
=
1
z_1135
=
x_1134
def
g1524
(
y_1137
):
return
(
x_1136
)
+
((
z_1135
)
+
(
y_1137
))
return
g1524
f_1138
=
g1525
()
return
f_1138
(
f_1138
(
x_1134
))
def
g1535
():
"""
>>> g1535()
3050
"""
def
g1534
():
def
g1533
():
def
g1531
(
t_1141
):
def
g1532
(
f_1142
):
return
t_1141
(
f_1142
(
1000
))
return
g1532
return
g1531
def
g1530
():
def
g1529
(
x_1140
):
return
(
x_1140
)
+
(
50
)
return
g1529
return
g1533
()(
g1530
())
def
g1528
():
def
g1527
(
y_1139
):
return
(
y_1139
)
+
(
2000
)
return
g1527
return
g1534
()(
g1528
())
def
g1540
():
"""
>>> g1540()
2050
"""
def
g1539
():
t_1143
=
50
def
g1538
(
f_1144
):
return
(
t_1143
)
+
(
f_1144
())
return
g1538
def
g1537
():
def
g1536
():
return
2000
return
g1536
return
g1539
()(
g1537
())
def
g1547
():
"""
>>> g1547()
2050
"""
def
g1546
():
def
g1545
():
def
g1543
(
t_1145
):
def
g1544
(
f_1146
):
return
(
t_1145
)
+
(
f_1146
())
return
g1544
return
g1543
return
g1545
()(
50
)
def
g1542
():
def
g1541
():
return
2000
return
g1541
return
g1546
()(
g1542
())
def
g1550
():
"""
>>> g1550()
700
"""
def
g1549
():
x_1147
=
300
def
g1548
(
y_1148
):
return
(
x_1147
)
+
(
y_1148
)
return
g1548
return
g1549
()(
400
)
def
g1553
():
"""
>>> g1553()
0
"""
x_1152
=
3
def
g1552
():
def
g1551
(
x_1150
,
y_1149
):
return
x_1150
return
g1551
f_1151
=
g1552
()
if
(
f_1151
(
0
,
0
)):
return
f_1151
(
f_1151
(
0
,
0
),
x_1152
)
else
:
return
0
def
g1562
():
"""
>>> g1562()
False
"""
def
g1561
():
def
g1556
(
x_1153
):
def
g1560
():
def
g1559
():
return
isinstance
(
x_1153
,
list
)
if
(
g1559
()):
def
g1558
():
def
g1557
():
return
(
x_1153
[
0
])
return
(
g1557
()
==
0
)
return
(
not
g1558
())
else
:
return
False
if
(
g1560
()):
return
x_1153
else
:
return
False
return
g1556
f_1154
=
g1561
()
def
g1555
():
def
g1554
():
return
[
0
,[]]
return
[
0
,
g1554
()]
return
f_1154
(
g1555
())
def
g1570
():
"""
>>> g1570()
False
"""
def
g1569
():
def
g1563
(
x_1155
):
def
g1568
():
if
(
x_1155
):
def
g1567
():
def
g1566
():
return
isinstance
(
x_1155
,
list
)
if
(
g1566
()):
def
g1565
():
def
g1564
():
return
(
x_1155
[
0
])
return
(
g1564
()
==
0
)
return
(
not
g1565
())
else
:
return
False
return
(
not
g1567
())
else
:
return
False
if
(
g1568
()):
return
x_1155
else
:
return
False
return
g1563
f_1156
=
g1569
()
return
f_1156
(
0
)
def
g1575
():
"""
>>> g1575()
[]
"""
def
g1574
():
def
g1571
(
x_1157
):
def
g1573
():
def
g1572
():
return
isinstance
(
x_1157
,
list
)
if
(
g1572
()):
return
True
else
:
return
(
x_1157
==
[])
if
(
g1573
()):
return
x_1157
else
:
return
[]
return
g1571
f_1158
=
g1574
()
return
f_1158
(
0
)
def
g1578
():
"""
>>> g1578()
4
"""
y_1159
=
4
def
g1577
():
def
g1576
(
y_1160
):
return
y_1160
return
g1576
f_1161
=
g1577
()
return
f_1161
(
f_1161
(
y_1159
))
def
g1581
():
"""
>>> g1581()
0
"""
y_1162
=
4
def
g1580
():
def
g1579
(
x_1164
,
y_1163
):
return
0
return
g1579
f_1165
=
g1580
()
return
f_1165
(
f_1165
(
y_1162
,
y_1162
),
f_1165
(
y_1162
,
y_1162
))
def
g1584
():
"""
>>> g1584()
0
"""
y_1166
=
4
def
g1583
():
def
g1582
(
x_1168
,
y_1167
):
return
0
return
g1582
f_1169
=
g1583
()
return
f_1169
(
f_1169
(
y_1166
,
y_1166
),
f_1169
(
y_1166
,
f_1169
(
y_1166
,
y_1166
)))
def
g1587
():
"""
>>> g1587()
0
"""
y_1170
=
4
def
g1586
():
def
g1585
(
x_1172
,
y_1171
):
return
0
return
g1585
f_1173
=
g1586
()
return
f_1173
(
f_1173
(
y_1170
,
f_1173
(
y_1170
,
y_1170
)),
f_1173
(
y_1170
,
f_1173
(
y_1170
,
y_1170
)))
def
g1594
():
"""
>>> g1594()
4
"""
def
g1593
():
def
g1588
(
y_1174
):
def
g1592
():
def
g1591
(
f_1176
):
return
f_1176
(
f_1176
(
y_1174
))
return
g1591
def
g1590
():
def
g1589
(
y_1175
):
return
y_1175
return
g1589
return
g1592
()(
g1590
())
return
g1588
return
g1593
()(
4
)
def
g1598
():
"""
>>> g1598()
23
"""
def
g1597
():
def
g1596
(
x_1177
):
return
x_1177
return
g1596
f_1178
=
g1597
()
def
g1595
():
if
(
False
):
return
1
else
:
return
f_1178
(
22
)
return
(
g1595
()
+
1
)
def
g1603
():
"""
>>> g1603()
22
"""
def
g1602
():
def
g1601
(
x_1179
):
return
x_1179
return
g1601
f_1180
=
g1602
()
def
g1600
():
def
g1599
():
return
23
==
0
return
f_1180
(
g1599
())
if
(
g1600
()):
return
1
else
:
return
22
def
g1611
():
"""
>>> g1611()
5061
"""
def
g1610
():
def
g1609
(
x_1182
):
if
(
x_1182
):
return
(
not
x_1182
)
else
:
return
x_1182
return
g1609
f_1185
=
g1610
()
def
g1608
():
def
g1607
(
x_1181
):
return
(
10
)
*
(
x_1181
)
return
g1607
f2_1184
=
g1608
()
x_1183
=
23
def
g1606
():
def
g1605
():
def
g1604
():
return
x_1183
==
0
return
f_1185
(
g1604
())
if
(
g1605
()):
return
1
else
:
return
(
x_1183
)
*
(
f2_1184
((
x_1183
-
1
)))
return
(
g1606
()
+
1
)
def
g1614
():
"""
>>> g1614()
1
"""
def
g1613
():
def
g1612
():
return
0
return
g1612
f_1186
=
g1613
()
x_1187
=
f_1186
()
return
1
def
g1617
():
"""
>>> g1617()
1
"""
def
g1616
():
def
g1615
():
return
0
return
g1615
f_1188
=
g1616
()
f_1188
()
return
1
def
g1620
():
"""
>>> g1620()
4
"""
def
g1619
():
def
g1618
(
x_1189
):
return
x_1189
return
g1618
f_1190
=
g1619
()
if
(
True
):
f_1190
(
3
)
return
4
else
:
return
5
def
g1623
():
"""
>>> g1623()
6
"""
def
g1622
():
def
g1621
(
x_1191
):
return
x_1191
return
g1621
f_1192
=
g1622
()
(
f_1192
(
4
))
if
(
True
)
else
(
5
)
return
6
def
g1627
():
"""
>>> g1627()
120
"""
def
g1626
():
def
g1624
(
fact_1195
,
n_1194
,
acc_1193
):
def
g1625
():
return
n_1194
==
0
if
(
g1625
()):
return
acc_1193
else
:
return
fact_1195
(
fact_1195
,
(
n_1194
-
1
),
(
n_1194
)
*
(
acc_1193
))
return
g1624
fact_1196
=
g1626
()
return
fact_1196
(
fact_1196
,
5
,
1
)
def
g1632
():
"""
>>> g1632()
144
"""
def
g1631
():
def
g1628
(
b_1199
,
c_1198
,
a_1197
):
b_1203
=
(
b_1199
)
+
(
a_1197
)
def
g1630
():
def
g1629
():
a_1201
=
(
b_1199
)
+
(
b_1199
)
c_1200
=
(
c_1198
)
+
(
c_1198
)
return
(
a_1201
)
+
(
a_1201
)
return
(
a_1197
)
+
(
g1629
())
a_1202
=
g1630
()
return
(
a_1202
)
*
(
a_1202
)
return
g1628
return
g1631
()(
2
,
3
,
4
)
def
g1639
():
"""
>>> g1639()
3
"""
def
g1638
():
def
g1636
(
x_1204
):
def
g1637
():
return
x_1204
()
return
g1637
return
g1636
f_1205
=
g1638
()
def
g1635
():
def
g1634
():
def
g1633
():
return
3
return
g1633
return
f_1205
(
g1634
())
return
g1635
()()
def
g1646
():
"""
>>> g1646()
3628800
"""
def
g1645
():
def
g1643
(
x_1207
):
def
g1644
():
return
x_1207
==
0
if
(
g1644
()):
return
1
else
:
return
(
x_1207
)
*
(
f_1206
((
x_1207
)
-
(
1
)))
return
g1643
f_1206
=
g1645
()
q_1208
=
17
def
g1642
():
def
g1640
(
a_1209
):
q_1208
=
10
def
g1641
():
return
a_1209
(
q_1208
)
return
g1641
return
g1640
g_1210
=
g1642
()
return
g_1210
(
f_1206
)()
tests/run/closure_tests_3.pyx
0 → 100644
View file @
539d795c
This diff is collapsed.
Click to expand it.
tests/run/closure_tests_4.pyx
0 → 100644
View file @
539d795c
This diff is collapsed.
Click to expand it.
tests/run/lambda_tests.pyx
0 → 100644
View file @
539d795c
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment