| 1661 | |
| 1662 | |
| 1663 | def 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 | |
| 1687 | def test_some_self_pyfunction(): |