mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
add exit_tests
This commit is contained in:
parent
bcf4c637a7
commit
157a3475c1
@ -1686,6 +1686,7 @@ TEST(vm, exit_fn) {
|
|||||||
__platform_printf("BEGIN\r\n");
|
__platform_printf("BEGIN\r\n");
|
||||||
obj_run(pikaMain,
|
obj_run(pikaMain,
|
||||||
"i = 0\n"
|
"i = 0\n"
|
||||||
|
"PikaStdLib.MemChecker.now()\n"
|
||||||
"def test():\n"
|
"def test():\n"
|
||||||
" global i\n"
|
" global i\n"
|
||||||
" while True:\n"
|
" while True:\n"
|
||||||
@ -1695,6 +1696,7 @@ TEST(vm, exit_fn) {
|
|||||||
" exit()\n"
|
" exit()\n"
|
||||||
"while True:\n"
|
"while True:\n"
|
||||||
" test()\n");
|
" test()\n");
|
||||||
|
obj_run(pikaMain,"PikaStdLib.MemChecker.now()\n");
|
||||||
/* collect */
|
/* collect */
|
||||||
int i = obj_getInt(pikaMain, "i");
|
int i = obj_getInt(pikaMain, "i");
|
||||||
/* assert */
|
/* assert */
|
||||||
@ -1703,6 +1705,40 @@ TEST(vm, exit_fn) {
|
|||||||
obj_deinit(pikaMain);
|
obj_deinit(pikaMain);
|
||||||
EXPECT_EQ(pikaMemNow(), 0);
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(vm, exit_fn_issue_1) {
|
||||||
|
/* init */
|
||||||
|
pikaMemInfo.heapUsedMax = 0;
|
||||||
|
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||||
|
extern unsigned char pikaModules_py_a[];
|
||||||
|
obj_linkLibrary(pikaMain, pikaModules_py_a);
|
||||||
|
/* run */
|
||||||
|
__platform_printf("BEGIN\r\n");
|
||||||
|
obj_run(pikaMain,
|
||||||
|
"PikaStdLib.MemChecker.now()\n"
|
||||||
|
"def task1():\n"
|
||||||
|
" print('task1 hello')\n"
|
||||||
|
"\n"
|
||||||
|
"def task2():\n"
|
||||||
|
" print('task2 hello')\n"
|
||||||
|
"\n"
|
||||||
|
"def fake_runtask():\n"
|
||||||
|
" i = 0\n"
|
||||||
|
" while True:\n"
|
||||||
|
" i += 1\n"
|
||||||
|
" print(i)\n"
|
||||||
|
" if i == 10:\n"
|
||||||
|
" exit()\n"
|
||||||
|
" task1()\n"
|
||||||
|
" task2()\n"
|
||||||
|
"\n");
|
||||||
|
/* collect */
|
||||||
|
/* assert */
|
||||||
|
obj_run(pikaMain,"PikaStdLib.MemChecker.now()\n");
|
||||||
|
/* deinit */
|
||||||
|
obj_deinit(pikaMain);
|
||||||
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TEST(vm, pass_) {
|
TEST(vm, pass_) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user