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

Function test_flatMap_self_pymethod

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

Source from the content-addressed store, hash-verified

2265
2266
2267def test_flatMap_self_pymethod():
2268 items = ['Four', 'Three', 'One']
2269
2270 class Counter:
2271 def __init__(self):
2272 self.count = 0
2273
2274 def increment(self, element, index, array):
2275 self.count += 1
2276
2277 obj = Counter()
2278 assert obj.count == 0
2279 result = pm.eval("""
2280 (arr, increment, result) => {
2281 let jsObj = {count: 0}
2282 arr.flatMap(increment, jsObj);
2283 return jsObj.count;
2284 }
2285 """)(items, obj.increment)
2286 assert obj.count == 0
2287 assert result == 3
2288
2289
2290def test_flatMap_self_pyfunction():

Callers

nothing calls this directly

Calls 1

CounterClass · 0.85

Tested by

no test coverage detected