Skip to content

Commit 64c0d5c

Browse files
test: updated devmode.adv.test.js
1 parent 938fa52 commit 64c0d5c

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

test/suite/integration/devmode.adv.test.js

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,37 @@ test("can fake deepsleep in devmode", async () => {
5757
});
5858

5959
test("can import fake_machine in devmode", async () => {
60-
const result = await device.runScript("import fake_machine\nfake_machine.sleep(1)");
61-
console.log("result", result);
60+
device.runScript("import fake_machine\nfake_machine.sleep(1)");
61+
await readUntil("fake_machine.sleep end");
6262
});
63+
64+
test("machine.sleep gets transformed to fake_machine.sleep", async () => {
65+
writeFileSync(
66+
projectPath1 + "/main.py",
67+
["import machine", "# machine.sleep(100)", "# machine.deepSleep(100)", 'print("booted")'].join("\n")
68+
);
69+
await readUntil("booted");
70+
const result = await device.adapter.getFile("main.py");
71+
assert.equal(
72+
result.toString(),
73+
["import fake_machine", "# fake_machine.sleep(100)", "# fake_machine.sleep(100)", 'print("booted")'].join("\n")
74+
);
75+
});
76+
77+
// todo can't interrupt loop. needs fix
78+
// solution could be to have fake_machine.sleep print an event indicating a 100ms window for sending ctrl+f
79+
80+
// test("main.py with deepsleep keeps looping", async () => {
81+
// let madeItPastSleep = false; // should stay false
82+
// writeFileSync(
83+
// projectPath1 + "/main.py",
84+
// ["import machine", "", 'print("before sleep")', "machine.sleep(100)", 'print("after sleep")'].join("\n")
85+
// );
86+
// readUntil("after sleep").then(() => (madeItPastSleep = true));
87+
// await readUntil("before sleep");
88+
// await readUntil("before sleep");
89+
// await readUntil("before sleep");
90+
// assert(!madeItPastSleep);
91+
// });
6392
});
6493
});

0 commit comments

Comments
 (0)