| 1927 | |
| 1928 | |
| 1929 | def test_find_self_pymethod(): |
| 1930 | items = ['Four', 'Three', 'One'] |
| 1931 | |
| 1932 | class Counter: |
| 1933 | def __init__(self): |
| 1934 | self.count = 0 |
| 1935 | |
| 1936 | def increment(self, element, index, array): |
| 1937 | self.count += 1 |
| 1938 | return False |
| 1939 | |
| 1940 | obj = Counter() |
| 1941 | assert obj.count == 0 |
| 1942 | result = pm.eval(""" |
| 1943 | (arr, increment, result) => { |
| 1944 | let jsObj = {count: 0} |
| 1945 | arr.find(increment, jsObj); |
| 1946 | return jsObj.count; |
| 1947 | } |
| 1948 | """)(items, obj.increment) |
| 1949 | assert obj.count == 0 |
| 1950 | assert result == 3 |
| 1951 | |
| 1952 | |
| 1953 | def test_find_self_pyfunction(): |