MCPcopy Create free account
hub / github.com/Distributive-Network/PythonMonkey / test_map_self_pymethod

Function test_map_self_pymethod

tests/python/test_arrays.py:1204–1224  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1202
1203
1204def test_map_self_pymethod():
1205 items = ['Four', 'Three', 'One']
1206
1207 class Counter:
1208 def __init__(self):
1209 self.count = 0
1210
1211 def increment(self, element, index, array):
1212 self.count += 1
1213
1214 obj = Counter()
1215 assert obj.count == 0
1216 result = pm.eval("""
1217 (arr, increment, result) => {
1218 let jsObj = {count: 0}
1219 arr.map(increment, jsObj);
1220 return jsObj.count;
1221 }
1222 """)(items, obj.increment)
1223 assert obj.count == 0
1224 assert result == 3
1225
1226
1227def test_map_self_pyfunction():

Callers

nothing calls this directly

Calls 1

CounterClass · 0.85

Tested by

no test coverage detected