MCPcopy
hub / github.com/pyodide/pyodide / test_jsarray_count

Function test_jsarray_count

src/tests/test_jsproxy.py:1791–1818  ·  view source on GitHub ↗
(selenium)

Source from the content-addressed store, hash-verified

1789
1790@run_in_pyodide
1791def test_jsarray_count(selenium):
1792 from pyodide.code import run_js
1793
1794 l = [5, 7, 9, -1, 3, 5]
1795 a = run_js(repr(l))
1796 assert a.count(1) == 0
1797 assert a.count(-1) == 1
1798 assert a.count(5) == 2
1799
1800 b = run_js(f"new Int8Array({repr(l)})")
1801 assert b.count(1) == 0
1802 assert b.count(-1) == 1
1803 assert b.count(5) == 2
1804
1805 a.append([])
1806 a.append([1])
1807 a.append([])
1808 assert a.count([]) == 2
1809 assert a.count([1]) == 1
1810 assert a.count([2]) == 0
1811 run_js(
1812 """(a) => {
1813 a.pop().destroy();
1814 a.pop().destroy();
1815 a.pop().destroy();
1816 }
1817 """
1818 )(a)
1819
1820
1821@run_in_pyodide

Callers

nothing calls this directly

Calls 3

run_jsFunction · 0.90
countMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…