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

Function test_find_self_pymethod

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

Source from the content-addressed store, hash-verified

1927
1928
1929def 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
1953def test_find_self_pyfunction():

Callers

nothing calls this directly

Calls 1

CounterClass · 0.85

Tested by

no test coverage detected