pikapython/test/compile-test.cpp

643 lines
19 KiB
C
Raw Normal View History

#include "test_common.h"
2022-04-29 01:13:41 +08:00
2022-04-27 19:19:14 +08:00
TEST(compiler, file) {
2022-04-30 21:17:19 +08:00
char* lines =
"len = calls.len()\n"
2022-04-27 19:19:14 +08:00
"mode = 'none'\n"
"info_index = 0\n"
"for i in range(0, len):\n"
" if len == 0:\n"
" break\n"
" if info_index == 0:\n"
" mode = calls[i]\n"
2022-04-27 19:19:14 +08:00
" info_index = 1\n"
" elif info_index == 1:\n"
" if mode == 'always':\n"
" todo = calls[i]\n"
2022-04-27 19:19:14 +08:00
" todo()\n"
" info_index = 0\n"
" elif mode == 'when':\n"
" when = calls[i]\n"
2022-04-27 19:19:14 +08:00
" info_index = 2\n"
" elif mode == 'period_ms':\n"
" period_ms = calls[i]\n"
2022-04-27 19:19:14 +08:00
" info_index = 2\n"
" elif info_index == 2:\n"
" if mode == 'when':\n"
" if when():\n"
" todo = calls[i]\n"
2022-04-27 19:19:14 +08:00
" todo()\n"
" info_index = 0\n"
" elif mode == 'period_ms':\n"
" todo = calls[i]\n"
2022-04-27 19:19:14 +08:00
" info_index = 3\n"
" elif info_index == 3:\n"
" if mode == 'period_ms':\n"
" if tick > calls[i]:\n"
2022-04-27 19:19:14 +08:00
" todo()\n"
" calls[i] = tick + period_ms\n"
2022-04-27 19:19:14 +08:00
" info_index = 0\n"
"\n";
2022-04-30 21:17:19 +08:00
pikaCompile("task.bin", lines);
Parser_linesToArray(lines);
2022-04-27 19:19:14 +08:00
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(compiler, task) {
2022-04-30 21:17:19 +08:00
char* lines =
"len = calls.len()\n"
2022-04-27 19:19:14 +08:00
"mode = 'none'\n"
"info_index = 0\n"
"for i in range(0, len):\n"
" if len == 0:\n"
" break\n"
" if info_index == 0:\n"
" mode = calls[i]\n"
2022-04-27 19:19:14 +08:00
" info_index = 1\n"
" elif info_index == 1:\n"
" if mode == 'always':\n"
" todo = calls[i]\n"
2022-04-27 19:19:14 +08:00
" todo()\n"
" info_index = 0\n"
" elif mode == 'when':\n"
" when = calls[i]\n"
2022-04-27 19:19:14 +08:00
" info_index = 2\n"
" elif mode == 'period_ms':\n"
" period_ms = calls[i]\n"
2022-04-27 19:19:14 +08:00
" info_index = 2\n"
" elif info_index == 2:\n"
" if mode == 'when':\n"
" if when():\n"
" todo = calls[i]\n"
2022-04-27 19:19:14 +08:00
" todo()\n"
" info_index = 0\n"
" elif mode == 'period_ms':\n"
" todo = calls[i]\n"
2022-04-27 19:19:14 +08:00
" info_index = 3\n"
" elif info_index == 3:\n"
" if mode == 'period_ms':\n"
" if tick > calls[i]:\n"
2022-04-27 19:19:14 +08:00
" todo()\n"
" calls[i] = tick + period_ms\n"
2022-04-27 19:19:14 +08:00
" info_index = 0\n"
"\n";
Args buffs = {0};
char* pikaAsm = Parser_linesToAsm(&buffs, lines);
2022-04-27 19:19:14 +08:00
ByteCodeFrame bytecode_frame;
byteCodeFrame_init(&bytecode_frame);
byteCodeFrame_appendFromAsm(&bytecode_frame, pikaAsm);
/* do something */
byteCodeFrame_print(&bytecode_frame);
printf("Asm size: %d\r\n", (int)strGetSize(pikaAsm));
2022-04-27 19:19:14 +08:00
byteCodeFrame_printAsArray(&bytecode_frame);
/* deinit */
byteCodeFrame_deinit(&bytecode_frame);
strsDeinit(&buffs);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(compiler, demo1) {
2022-04-30 21:17:19 +08:00
char* lines = "append(__val)";
Parser_linesToArray(lines);
2022-04-27 19:19:14 +08:00
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(compiler, snake_file) {
2022-04-30 21:17:19 +08:00
char* lines =
2022-04-27 19:19:14 +08:00
"from PikaObj import *\n"
"import PikaStdLib\n"
"import machine \n"
"\n"
"# hardware init\n"
"lcd = machine.LCD()\n"
"lcd.init()\n"
"lcd.clear('white')\n"
"key = machine.KEY()\n"
"key.init()\n"
"time = machine.Time()\n"
"x_max = 120\n"
"y_max = 150\n"
"\n"
"# snake init\n"
"s = machine.Point()\n"
"w = 9\n"
"h = 9\n"
"s.x = 50\n"
"s.y = 10\n"
"len = 0\n"
"while len < 3:\n"
" b = s\n"
" i = 0\n"
" while i < len:\n"
" b = b.next\n"
" i = i + 1\n"
" b.next = machine.Point()\n"
" b.next.x = b.x - 10\n"
" b.next.y = b.y\n"
" b.next.prev = b\n"
" len = len + 1\n"
"# ring link\n"
"b.next = s\n"
"s.prev = b\n"
"\n"
"i = 0\n"
"b = s\n"
"while i < len:\n"
" lcd.fill(b.x, b.y, w, h, 'blue')\n"
" b = b.next\n"
" i = i + 1\n"
"\n"
"print('snake lengh')\n"
"print(len)\n"
"\n"
"# fruit init\n"
"f = machine.Point()\n"
"f.x = 30\n"
"f.y = 20\n"
"lcd.fill(f.x, f.y, w, h, 'green')\n"
"\n"
"# memory check\n"
"mem = PikaStdLib.MemChecker()\n"
"print('mem used max:')\n"
"mem.max()\n"
"\n"
"# main loop\n"
"d = 0\n"
"isUpdate = 1\n"
"isEat = 0\n"
"while True:\n"
" if isUpdate:\n"
" # isUpdate = 0\n"
" # check eat fruit\n"
" if f.x == s.x and f.y == s.y:\n"
" # have eat fruit\n"
" isEat = 1\n"
" f.x = f.x + 30\n"
" if f.x > x_max:\n"
" f.x = f.x - x_max\n"
" f.y = f.y + 30\n"
" if f.y > y_max:\n"
" f.y = f.y - y_max\n"
" lcd.fill(f.x, f.y, w, h, 'green')\n"
" # move snake by the direction\n"
" if d == 0:\n"
" x_new = s.x + 10\n"
" y_new = s.y\n"
" if x_new > x_max:\n"
" x_new = 0\n"
" elif d == 1:\n"
" x_new = s.x\n"
" y_new = s.y - 10\n"
" if y_new < 0:\n"
" y_new = y_max\n"
" elif d == 2:\n"
" x_new = s.x\n"
" y_new = s.y + 10\n"
" if y_new > y_max:\n"
" y_new = 0\n"
" elif d == 3:\n"
" x_new = s.x - 10\n"
" y_new = s.y\n"
" if x_new < 0:\n"
" x_new = x_max\n"
" if isEat:\n"
" isEat = 0\n"
" b_new = machine.Point()\n"
" b_new.x = x_new\n"
" b_new.y = y_new\n"
" b_new.prev = s.prev\n"
" b_new.next = s\n"
" s.prev.next = b_new\n"
" s.prev = b_new\n"
" s = b_new\n"
" len = len + 1\n"
" print('snake lengh')\n"
" print(len)\n"
" print('mem used max:')\n"
" mem.max()\n"
" # drow the snake and fruit\n"
" # clear last body\n"
" lcd.fill(s.prev.x, s.prev.y, w, h, 'white')\n"
" # new body\n"
" s.prev.x = x_new\n"
" s.prev.y = y_new\n"
" # head is last body\n"
" s = s.prev\n"
" lcd.fill(s.x, s.y, w, h, 'blue')\n"
" b = s\n"
" i = 0\n"
" # scan key\n"
" key_val = key.get()\n"
" if key_val == 0:\n"
" d = 0\n"
" isUpdate = 1\n"
" elif key_val == 1:\n"
" d = 1\n"
" isUpdate = 1\n"
" elif key_val == 2:\n"
" d = 2\n"
" isUpdate = 1\n"
" elif key_val == 3:\n"
" d = 3\n"
" isUpdate = 1\n";
2022-04-30 21:17:19 +08:00
pikaCompile("snake.bin", lines);
2022-04-27 19:19:14 +08:00
EXPECT_EQ(pikaMemNow(), 0);
2022-04-28 16:55:48 +08:00
}
TEST(compiler, import_bf_mem) {
2022-04-30 21:17:19 +08:00
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
char* lines =
2022-04-28 16:55:48 +08:00
"def mytest():\n"
" print('test')\n"
"\n";
ByteCodeFrame bf;
byteCodeFrame_init(&bf);
bytecodeFrame_fromLines(&bf, lines);
2022-04-30 21:17:19 +08:00
obj_importModuleWithByteCodeFrame(pikaMain, "mtest", &bf);
2022-04-28 16:55:48 +08:00
byteCodeFrame_deinit(&bf);
obj_deinit(pikaMain);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(compiler, import_bf1) {
2022-04-30 21:17:19 +08:00
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
char* lines =
2022-04-28 16:55:48 +08:00
"def mytest():\n"
" print('test_import_bf1')\n"
"\n";
ByteCodeFrame bf;
byteCodeFrame_init(&bf);
bytecodeFrame_fromLines(&bf, lines);
2022-04-30 21:17:19 +08:00
obj_importModuleWithByteCodeFrame(pikaMain, "mtest", &bf);
2022-04-30 22:40:52 +08:00
obj_run(pikaMain,
2022-04-28 16:55:48 +08:00
"mtest.mytest()\n"
2022-04-30 22:40:52 +08:00
"\n");
2022-04-28 16:55:48 +08:00
EXPECT_STREQ(log_buff[0], "test_import_bf1\r\n");
byteCodeFrame_deinit(&bf);
obj_deinit(pikaMain);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(compiler, import_bf2) {
2022-04-30 21:17:19 +08:00
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
char* lines =
2022-04-28 16:55:48 +08:00
"class Test:\n"
" def mytest(self):\n"
" print('test_import_bf2')\n"
"\n";
ByteCodeFrame bf;
byteCodeFrame_init(&bf);
bytecodeFrame_fromLines(&bf, lines);
2022-04-30 21:17:19 +08:00
obj_importModuleWithByteCodeFrame(pikaMain, "mtest", &bf);
2022-04-30 22:40:52 +08:00
obj_run(pikaMain,
2022-04-28 16:55:48 +08:00
"m = mtest.Test()\n"
"m.mytest()\n"
2022-04-30 22:40:52 +08:00
"\n");
2022-04-28 16:55:48 +08:00
byteCodeFrame_deinit(&bf);
obj_deinit(pikaMain);
EXPECT_STREQ(log_buff[0], "test_import_bf2\r\n");
EXPECT_EQ(pikaMemNow(), 0);
}
2022-04-29 01:24:28 +08:00
TEST(compiler, file1) {
2022-04-30 21:17:19 +08:00
pikaCompileFile("test/python/main.py");
2022-04-29 01:24:28 +08:00
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(compiler, file2) {
2022-04-30 21:17:19 +08:00
pikaCompileFile("test/python/main_snake_LCD.py");
2022-04-29 01:24:28 +08:00
EXPECT_EQ(pikaMemNow(), 0);
}
2022-04-29 23:56:25 +08:00
TEST(lib, init) {
2022-05-11 19:57:59 +08:00
LibObj* lib = New_LibObj(NULL);
2022-04-30 22:40:52 +08:00
LibObj_deinit(lib);
2022-04-29 23:56:25 +08:00
EXPECT_EQ(pikaMemNow(), 0);
}
2022-04-30 21:13:42 +08:00
TEST(lib, lib_link_bytecode) {
2022-05-11 19:57:59 +08:00
LibObj* lib = New_LibObj(NULL);
2022-04-30 23:13:05 +08:00
LibObj_dynamicLink(lib, "module1", (uint8_t*)0x3344);
2022-05-01 00:02:19 +08:00
LibObj_dynamicLink(lib, "module2", (uint8_t*)0x33433);
LibObj_dynamicLink(lib, "module3", (uint8_t*)0x33433);
LibObj_dynamicLink(lib, "module4", (uint8_t*)0x33433);
LibObj_dynamicLink(lib, "module5", (uint8_t*)0x33433);
2022-05-01 21:07:41 +08:00
EXPECT_STREQ(obj_getStr(lib, "module1.name"), "module1");
EXPECT_EQ((uintptr_t)obj_getPtr(lib, "module1.bytecode"), 0x3344);
2022-04-30 21:13:42 +08:00
/* deinit */
2022-04-30 22:40:52 +08:00
LibObj_deinit(lib);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(lib, lib_push_file) {
2022-05-11 19:57:59 +08:00
LibObj* lib = New_LibObj(NULL);
2022-04-30 23:13:05 +08:00
LibObj_staticLinkFile(lib, "test/python/main.py.o");
2022-04-30 22:40:52 +08:00
/* deinit */
LibObj_deinit(lib);
2022-04-30 21:13:42 +08:00
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(lib, lib_push_files) {
2022-05-11 19:57:59 +08:00
LibObj* lib = New_LibObj(NULL);
2022-04-30 23:13:05 +08:00
LibObj_staticLinkFile(lib, "test/python/main.py.o");
LibObj_staticLinkFile(lib, "test/python/main_snake_LCD.py.o");
LibObj_listModules(lib);
/* asset */
EXPECT_STREQ(log_buff[0], "main\r\n");
EXPECT_STREQ(log_buff[1], "main_snake_LCD\r\n");
/* deinit */
LibObj_deinit(lib);
EXPECT_EQ(pikaMemNow(), 0);
}
2022-04-30 23:51:25 +08:00
TEST(lib, lib_compile_link) {
2022-05-11 19:57:59 +08:00
LibObj* lib = New_LibObj(NULL);
2022-04-30 23:53:28 +08:00
2022-04-30 23:51:25 +08:00
pikaCompileFile("test/python/UnitTest.py");
pikaCompileFile("test/python/main.py");
pikaCompileFile("test/python/main_snake_LCD.py");
2022-04-30 23:53:28 +08:00
2022-04-30 23:51:25 +08:00
LibObj_staticLinkFile(lib, "test/python/UnitTest.py.o");
LibObj_staticLinkFile(lib, "test/python/main.py.o");
LibObj_staticLinkFile(lib, "test/python/main_snake_LCD.py.o");
2022-04-30 23:53:28 +08:00
2022-04-30 23:51:25 +08:00
LibObj_listModules(lib);
/* asset */
EXPECT_STREQ(log_buff[0], "UnitTest\r\n");
2022-04-30 23:52:41 +08:00
EXPECT_STREQ(log_buff[1], "main\r\n");
EXPECT_STREQ(log_buff[2], "main_snake_LCD\r\n");
2022-04-30 23:51:25 +08:00
/* deinit */
LibObj_deinit(lib);
EXPECT_EQ(pikaMemNow(), 0);
}
2022-05-01 17:08:24 +08:00
TEST(lib, compile_link_import) {
2022-05-11 19:57:59 +08:00
LibObj* lib = New_LibObj(NULL);
2022-05-01 17:08:24 +08:00
pikaCompileFile("test/python/test_module1.py");
LibObj_staticLinkFile(lib, "test/python/test_module1.py.o");
LibObj_listModules(lib);
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
2022-05-11 19:57:59 +08:00
obj_linkLibObj(pikaMain, lib);
2022-05-01 17:08:24 +08:00
obj_run(pikaMain,
"import test_module1\n"
"test_module1.mytest()\n");
/* asset */
EXPECT_STREQ(log_buff[0], "test_module_1_hello\r\n");
/* deinit */
LibObj_deinit(lib);
obj_deinit(pikaMain);
EXPECT_EQ(pikaMemNow(), 0);
}
2022-05-02 01:54:28 +08:00
TEST(lib, lib_to_file) {
2022-05-11 19:57:59 +08:00
LibObj* lib = New_LibObj(NULL);
2022-05-02 01:54:28 +08:00
pikaCompileFile("test/python/UnitTest.py");
pikaCompileFile("test/python/main.py");
pikaCompileFile("test/python/main_snake_LCD.py");
LibObj_staticLinkFile(lib, "test/python/UnitTest.py.o");
LibObj_staticLinkFile(lib, "test/python/main.py.o");
LibObj_staticLinkFile(lib, "test/python/main_snake_LCD.py.o");
LibObj_listModules(lib);
2022-05-02 14:48:10 +08:00
LibObj_saveLibraryFile(lib, "test/python/lib_to_file.py.a");
2022-05-02 01:54:28 +08:00
/* asset */
EXPECT_STREQ(log_buff[0], "UnitTest\r\n");
EXPECT_STREQ(log_buff[1], "main\r\n");
EXPECT_STREQ(log_buff[2], "main_snake_LCD\r\n");
/* deinit */
LibObj_deinit(lib);
EXPECT_EQ(pikaMemNow(), 0);
}
2022-05-02 21:29:10 +08:00
TEST(lib, save2) {
2022-05-11 19:57:59 +08:00
LibObj* lib = New_LibObj(NULL);
2022-05-02 21:29:10 +08:00
pikaCompileFile("test/python/test_module1.py");
pikaCompileFile("test/python/test_module2.py");
pikaCompileFile("test/python/test_module3.py");
LibObj_staticLinkFile(lib, "test/python/test_module1.py.o");
LibObj_staticLinkFile(lib, "test/python/test_module2.py.o");
LibObj_staticLinkFile(lib, "test/python/test_module3.py.o");
LibObj_listModules(lib);
LibObj_saveLibraryFile(lib, "test/python/test_module.py.a");
/* asset */
EXPECT_STREQ(log_buff[0], "test_module1\r\n");
EXPECT_STREQ(log_buff[1], "test_module2\r\n");
EXPECT_STREQ(log_buff[2], "test_module3\r\n");
/* deinit */
LibObj_deinit(lib);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(lib, load_file) {
/* compile */
2022-05-11 19:57:59 +08:00
LibObj* lib = New_LibObj(NULL);
2022-05-02 21:29:10 +08:00
LibObj_loadLibraryFile(lib, "test/python/test_module.py.a");
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
2022-05-11 19:57:59 +08:00
obj_linkLibObj(pikaMain, lib);
2022-05-02 21:29:10 +08:00
obj_run(pikaMain,
"import test_module1\n"
"import test_module2\n"
"import test_module3\n"
"test_module1.mytest()\n"
"test_module2.mytest()\n"
2022-05-04 16:53:07 +08:00
"test_module3.mytest()\n");
2022-05-02 21:29:10 +08:00
/* asset */
EXPECT_STREQ(log_buff[2], "test_module_1_hello\r\n");
EXPECT_STREQ(log_buff[1], "test_module_2_hello\r\n");
EXPECT_STREQ(log_buff[0], "test_module_3_hello\r\n");
/* deinit */
LibObj_deinit(lib);
obj_deinit(pikaMain);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(lib, load_no_file) {
/* compile */
2022-05-11 19:57:59 +08:00
LibObj* lib = New_LibObj(NULL);
int res = LibObj_loadLibraryFile(lib, "test/python/mian.py.o");
EXPECT_EQ(res, PIKA_RES_ERR_IO_ERROR);
/* deinit */
LibObj_deinit(lib);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(lib, load_err_file_type) {
/* compile */
2022-05-11 19:57:59 +08:00
LibObj* lib = New_LibObj(NULL);
int res = LibObj_loadLibraryFile(lib, "test/python/main.py.o");
EXPECT_EQ(res, PIKA_RES_ERR_OPERATION_FAILED);
/* deinit */
LibObj_deinit(lib);
EXPECT_EQ(pikaMemNow(), 0);
}
2022-05-04 16:53:07 +08:00
TEST(lib, lib_file_to_array) {
2022-05-06 18:49:46 +08:00
Lib_loadLibraryFileToArray("test/python/lib_to_file.py.a", "test/python");
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(make, maker) {
PikaMaker* maker = New_PikaMaker();
obj_deinit(maker);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(make, compile) {
PikaMaker* maker = New_PikaMaker();
pikaMaker_setPWD(maker, "package/pikascript/");
pikaMaker_compileModule(maker, "main");
obj_deinit(maker);
EXPECT_EQ(pikaMemNow(), 0);
2022-05-04 16:53:07 +08:00
}
2022-05-07 14:46:24 +08:00
TEST(make, depend) {
PikaMaker* maker = New_PikaMaker();
pikaMaker_setPWD(maker, "package/pikascript/");
pikaMaker_getDependencies(maker, "main");
pikaMaker_printStates(maker);
2022-05-13 09:04:54 +08:00
// char* uncompiled = pikaMaker_getFirstNocompiled(maker);
// EXPECT_STREQ(uncompiled, "test_module1");
2022-05-11 16:07:27 +08:00
obj_deinit(maker);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(make, compile_depend) {
PikaMaker* maker = New_PikaMaker();
pikaMaker_setPWD(maker, "package/pikascript/");
pikaMaker_getDependencies(maker, "main");
char* uncompiled = pikaMaker_getFirstNocompiled(maker);
pikaMaker_compileModule(maker, uncompiled);
pikaMaker_getDependencies(maker, uncompiled);
uncompiled = pikaMaker_getFirstNocompiled(maker);
2022-05-13 09:04:54 +08:00
// EXPECT_STREQ(uncompiled, "test_module3");
2022-05-11 16:07:27 +08:00
pikaMaker_printStates(maker);
2022-05-07 14:46:24 +08:00
obj_deinit(maker);
EXPECT_EQ(pikaMemNow(), 0);
}
2022-05-11 16:10:27 +08:00
TEST(make, compile_depend_all) {
PikaMaker* maker = New_PikaMaker();
pikaMaker_setPWD(maker, "package/pikascript/");
2022-05-11 16:41:34 +08:00
pikaMaker_compileModuleWithDepends(maker, "main");
2022-05-11 16:10:27 +08:00
pikaMaker_printStates(maker);
obj_deinit(maker);
EXPECT_EQ(pikaMemNow(), 0);
}
2022-05-11 18:21:24 +08:00
TEST(make, compile_link_all) {
PikaMaker* maker = New_PikaMaker();
pikaMaker_setPWD(maker, "package/pikascript/");
pikaMaker_compileModuleWithDepends(maker, "main");
pikaMaker_printStates(maker);
2022-05-25 13:46:48 +08:00
pikaMaker_linkCompiledModules(maker, "pikaModules.py.a");
2022-05-11 18:21:24 +08:00
obj_deinit(maker);
EXPECT_EQ(pikaMemNow(), 0);
}
2022-05-25 13:46:48 +08:00
TEST(compiler, __str__) {
char* lines = "__res = __str__()";
Parser_linesToArray(lines);
2022-05-25 13:46:48 +08:00
EXPECT_EQ(pikaMemNow(), 0);
}
2022-06-02 14:23:55 +08:00
TEST(compiler, __len__) {
char* lines = "__res = __len__()";
Parser_linesToArray(lines);
EXPECT_EQ(pikaMemNow(), 0);
}
2022-06-02 14:23:55 +08:00
TEST(compiler, __del__) {
char* lines = "__del__()";
Parser_linesToArray(lines);
2022-06-02 14:23:55 +08:00
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(compiler, event_cb) {
char* lines = "_eventCallBack(_eventSignal)";
Parser_linesToArray(lines);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(compiler, event_cb_lvgl) {
char* lines = "eventCallBack(eventSignal)";
Parser_linesToArray(lines);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(compiler, __setitem__) {
char* lines = "__setitem__(__key, __val)";
Parser_linesToArray(lines);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(compiler, __getitem__) {
char* lines = "__res = __getitem__(__key)";
Parser_linesToArray(lines);
EXPECT_EQ(pikaMemNow(), 0);
}
2022-08-16 17:40:11 +08:00
TEST(compiler, __add__) {
char* lines = "__res = __add__(__others)";
Parser_linesToArray(lines);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(compiler, __sub__) {
char* lines = "__res = __sub__(__others)";
Parser_linesToArray(lines);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(compiler, __contains__) {
char* lines = "__res = __contains__(__others)";
Parser_linesToArray(lines);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(compiler, __callback) {
char* lines = "__callback(__frameBuffer, __isNewFrame)";
Parser_linesToArray(lines);
EXPECT_EQ(pikaMemNow(), 0);
}
2022-09-19 09:53:27 +08:00
TEST(compiler, __list) {
char* lines =
"__res = []\n"
"for __item in __list:\n"
" __res.append(__item)\n"
"del __item\n"
"del __list\n";
Parser_linesToArray(lines);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(compiler, getattr) {
char* lines = "@res = __getattribute__(@name)";
Parser_linesToArray(lines);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(compiler, getattr2) {
char* lines = "@res = __getattr__(@name)";
Parser_linesToArray(lines);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(compiler, setattr) {
char* lines = "__setattr__(@name, @value)";
Parser_linesToArray(lines);
EXPECT_EQ(pikaMemNow(), 0);
}