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
@ -801,7 +801,7 @@ TEST(VM, for_break_byte) {
|
||||
|
||||
TEST(VM, load_static_bytes) {
|
||||
const uint8_t bytes[] = {
|
||||
0x08, 0x02, 0x00, 0x00,/* instruct array size */
|
||||
0x08, 0x02, 0x00, 0x00, /* instruct array size */
|
||||
0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x0d, 0x00, 0x00, 0x83, 0x11, 0x00,
|
||||
0x00, 0x04, 0x16, 0x00, 0x00, 0x85, 0x1b, 0x00, 0x00, 0x04, 0x1d, 0x00,
|
||||
0x20, 0x85, 0x1b, 0x00, 0x20, 0x01, 0x0d, 0x00, 0x10, 0x02, 0x28, 0x00,
|
||||
@ -846,7 +846,7 @@ TEST(VM, load_static_bytes) {
|
||||
0x14, 0x08, 0xa4, 0x00, 0x14, 0x03, 0x6e, 0x00, 0x04, 0x02, 0xa6, 0x00,
|
||||
0x03, 0x85, 0x1b, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x00, 0x86, 0xae, 0x00,
|
||||
0x00, 0x8c, 0x33, 0x00, /* instruct array */
|
||||
0xb1, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0xb1, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x5f, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x2e, 0x6c, 0x65, 0x6e,
|
||||
0x00, 0x6c, 0x65, 0x6e, 0x00, 0x6e, 0x6f, 0x6e, 0x65, 0x00, 0x6d, 0x6f,
|
||||
0x64, 0x65, 0x00, 0x30, 0x00, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x69, 0x6e,
|
||||
@ -1686,6 +1686,7 @@ TEST(vm, exit_fn) {
|
||||
__platform_printf("BEGIN\r\n");
|
||||
obj_run(pikaMain,
|
||||
"i = 0\n"
|
||||
"PikaStdLib.MemChecker.now()\n"
|
||||
"def test():\n"
|
||||
" global i\n"
|
||||
" while True:\n"
|
||||
@ -1695,6 +1696,7 @@ TEST(vm, exit_fn) {
|
||||
" exit()\n"
|
||||
"while True:\n"
|
||||
" test()\n");
|
||||
obj_run(pikaMain,"PikaStdLib.MemChecker.now()\n");
|
||||
/* collect */
|
||||
int i = obj_getInt(pikaMain, "i");
|
||||
/* assert */
|
||||
@ -1703,6 +1705,40 @@ TEST(vm, exit_fn) {
|
||||
obj_deinit(pikaMain);
|
||||
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
|
||||
|
||||
TEST(vm, pass_) {
|
||||
@ -1980,13 +2016,13 @@ TEST(vm, i_pp) {
|
||||
)
|
||||
/* clang-format on */
|
||||
const uint8_t bytes[] = {
|
||||
0x30, 0x00, 0x00, 0x00,/* instruct array size */
|
||||
0x30, 0x00, 0x00, 0x00, /* instruct array size */
|
||||
0x00, 0x85, 0x01, 0x00, 0x00, 0x04, 0x03, 0x00, 0x10, 0x81, 0x03, 0x00,
|
||||
0x10, 0x05, 0x05, 0x00, 0x00, 0x08, 0x0b, 0x00, 0x00, 0x07, 0x0d, 0x00,
|
||||
0x11, 0x81, 0x03, 0x00, 0x21, 0x05, 0x0f, 0x00, 0x11, 0x02, 0x00, 0x00,
|
||||
0x01, 0x08, 0x11, 0x00, 0x01, 0x04, 0x03, 0x00, 0x00, 0x86, 0x13, 0x00,
|
||||
/* instruct array */
|
||||
0x16, 0x00, 0x00, 0x00,/* const pool size */
|
||||
0x16, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x30, 0x00, 0x69, 0x00, 0x31, 0x30, 0x30, 0x30, 0x30, 0x00, 0x3c,
|
||||
0x00, 0x32, 0x00, 0x31, 0x00, 0x2b, 0x00, 0x2d, 0x31,
|
||||
0x00, /* const pool */
|
||||
@ -2024,7 +2060,7 @@ TEST(vm, benchmark) {
|
||||
)
|
||||
/* clang-format on */
|
||||
const uint8_t bytes[] = {
|
||||
0xac, 0x00, 0x00, 0x00,/* instruct array size */
|
||||
0xac, 0x00, 0x00, 0x00, /* instruct array size */
|
||||
0x00, 0x85, 0x01, 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x85, 0x07, 0x00,
|
||||
0x00, 0x04, 0x09, 0x00, 0x10, 0x81, 0x09, 0x00, 0x10, 0x05, 0x0b, 0x00,
|
||||
0x00, 0x08, 0x10, 0x00, 0x00, 0x07, 0x07, 0x00, 0x01, 0x85, 0x12, 0x00,
|
||||
@ -2040,7 +2076,7 @@ TEST(vm, benchmark) {
|
||||
0x02, 0x04, 0x03, 0x00, 0x11, 0x81, 0x09, 0x00, 0x21, 0x05, 0x12, 0x00,
|
||||
0x11, 0x02, 0x00, 0x00, 0x01, 0x08, 0x24, 0x00, 0x01, 0x04, 0x09, 0x00,
|
||||
0x00, 0x86, 0x26, 0x00, /* instruct array */
|
||||
0x29, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x29, 0x00, 0x00, 0x00, /* const pool size */
|
||||
0x00, 0x30, 0x00, 0x6e, 0x75, 0x6d, 0x00, 0x32, 0x00, 0x69, 0x00, 0x31,
|
||||
0x30, 0x30, 0x30, 0x00, 0x3c, 0x00, 0x31, 0x00, 0x69, 0x73, 0x5f, 0x70,
|
||||
0x72, 0x69, 0x6d, 0x65, 0x00, 0x6a, 0x00, 0x25, 0x00, 0x3d, 0x3d, 0x00,
|
||||
|
Loading…
x
Reference in New Issue
Block a user