From 581281ff8eb7db6ea64e8d7416e291310b0455b4 Mon Sep 17 00:00:00 2001 From: lyon Date: Tue, 25 Oct 2022 13:54:21 +0800 Subject: [PATCH] add stdtask test on REPL --- port/linux/package/pikascript/GTestTask.pyi | 1 + .../pikascript-lib/GTestTask/GTestTask.c | 6 ++++++ test/module-test.cpp | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/port/linux/package/pikascript/GTestTask.pyi b/port/linux/package/pikascript/GTestTask.pyi index dcd520234..d59633eb7 100644 --- a/port/linux/package/pikascript/GTestTask.pyi +++ b/port/linux/package/pikascript/GTestTask.pyi @@ -7,6 +7,7 @@ def __init__(self): ... class Task(PikaStdTask.Task): + def __init__(self): ... def platformGetTick(self): ... def returnNullString(self) -> str: ... diff --git a/port/linux/package/pikascript/pikascript-lib/GTestTask/GTestTask.c b/port/linux/package/pikascript/pikascript-lib/GTestTask/GTestTask.c index 572367271..c266f8451 100644 --- a/port/linux/package/pikascript/pikascript-lib/GTestTask/GTestTask.c +++ b/port/linux/package/pikascript/pikascript-lib/GTestTask/GTestTask.c @@ -9,6 +9,12 @@ void GTestTask_Task_platformGetTick(PikaObj* self) { obj_setInt(self, "tick", tick_ms); } +void PikaStdTask_Task___init__(PikaObj* self); +void GTestTask_Task___init__(PikaObj *self){ + PikaStdTask_Task___init__(self); + tick_ms = 0; +} + void GTestTask___init__(PikaObj* self) { if (!obj_isArgExist(self, "testval")) { obj_setInt(self, "testval", 8848); diff --git a/test/module-test.cpp b/test/module-test.cpp index f40baee49..3f1dd4279 100644 --- a/test/module-test.cpp +++ b/test/module-test.cpp @@ -472,4 +472,22 @@ TEST(module, REPL_big_script) { obj_deinit(pikaMain); EXPECT_EQ(pikaMemNow(), 0); } + +TEST(module, REPL_stdtask) { + /* 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"); + f_getchar_fp = fopen("test/python/std/stdtask.py", "rb"); + pikaScriptShell_withGetchar(pikaMain, f_getchar); + fclose((FILE*)f_getchar_fp); + /* collect */ + /* assert */ + /* deinit */ + obj_deinit(pikaMain); + EXPECT_EQ(pikaMemNow(), 0); +} #endif