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

Function test_find_check_this_arg

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

Source from the content-addressed store, hash-verified

1892
1893
1894def test_find_check_this_arg():
1895 items = ['Four', 'Three', 'One']
1896 result = [None]
1897 pm.eval(
1898 """
1899 (result, arr) => {
1900 class Counter {
1901 constructor()
1902 {
1903 this.count = 0;
1904 }
1905 add(array) {
1906 array.find(function countEntry(entry) { ++this.count; }, this);
1907 }
1908 }
1909 const obj = new Counter();
1910 obj.add(arr);
1911 result[0] = obj.count;
1912 }
1913 """
1914 )(result, items)
1915 assert result == [3]
1916
1917
1918def test_find_with_python_function():

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected