mirror of
https://github.com/micropython/micropython.git
synced 2026-01-21 03:17:18 +01:00
This test is not a PyProxy test, rather it's a JsProxy test. Signed-off-by: Damien George <damien@micropython.org>
27 lines
614 B
JavaScript
27 lines
614 B
JavaScript
// Test identity of PyProxy when they are the same Python object.
|
|
|
|
const mp = await (await import(process.argv[2])).loadMicroPython();
|
|
|
|
mp.runPython(`
|
|
l = []
|
|
`);
|
|
|
|
const l1 = mp.globals.get("l");
|
|
const l2 = mp.globals.get("l");
|
|
console.log(l1, l2);
|
|
console.log(l1 === l2);
|
|
|
|
globalThis.eventTarget = new EventTarget();
|
|
globalThis.event = new Event("event");
|
|
|
|
mp.runPython(`
|
|
import js
|
|
|
|
def callback(ev):
|
|
print("callback", ev)
|
|
js.eventTarget.addEventListener("event", callback)
|
|
js.eventTarget.dispatchEvent(js.event)
|
|
js.eventTarget.removeEventListener("event", callback)
|
|
js.eventTarget.dispatchEvent(js.event)
|
|
`);
|