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

Function test_some_self_pymethod

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

Source from the content-addressed store, hash-verified

1661
1662
1663def test_some_self_pymethod():
1664 items = ['Four', 'Three', 'One']
1665
1666 class Counter:
1667 def __init__(self):
1668 self.count = 0
1669
1670 def increment(self, element, index, array):
1671 self.count += 1
1672 return False
1673
1674 obj = Counter()
1675 assert obj.count == 0
1676 result = pm.eval("""
1677 (arr, increment, result) => {
1678 let jsObj = {count: 0}
1679 arr.some(increment, jsObj);
1680 return jsObj.count;
1681 }
1682 """)(items, obj.increment)
1683 assert obj.count == 0
1684 assert result == 3
1685
1686
1687def test_some_self_pyfunction():

Callers

nothing calls this directly

Calls 1

CounterClass · 0.85

Tested by

no test coverage detected