2022-05-19 20:52:19 +08:00
|
|
|
#include "test_common.h"
|
2021-10-01 00:21:50 +08:00
|
|
|
|
2021-10-31 00:04:00 +08:00
|
|
|
TEST(sysObj, print) {
|
2022-04-30 21:17:19 +08:00
|
|
|
PikaObj* obj = newRootObj("test", New_PikaStdLib_SysObj);
|
|
|
|
VMParameters* globals = obj_runDirect(obj, "print('hello world')");
|
2022-03-22 09:43:19 +08:00
|
|
|
// char* sysOut = args_getSysOut(globals->list);
|
2021-11-14 11:42:13 +08:00
|
|
|
int errCode = args_getErrorCode(globals->list);
|
2022-03-22 09:43:19 +08:00
|
|
|
// printf("sysout = %s\r\n", sysOut);
|
2022-01-03 21:51:42 +08:00
|
|
|
EXPECT_STREQ(log_buff[0], "hello world\r\n");
|
2022-04-30 21:17:19 +08:00
|
|
|
// ASSERT_STREQ("hello world", sysOut);
|
2021-10-31 00:04:00 +08:00
|
|
|
ASSERT_EQ(0, errCode);
|
2021-11-23 12:15:12 +08:00
|
|
|
// obj_deinit(globals);
|
2021-10-31 00:04:00 +08:00
|
|
|
obj_deinit(obj);
|
|
|
|
EXPECT_EQ(pikaMemNow(), 0);
|
|
|
|
}
|
2021-10-01 00:21:50 +08:00
|
|
|
|
2021-10-31 00:04:00 +08:00
|
|
|
TEST(sysObj, noMethod) {
|
2022-04-30 21:17:19 +08:00
|
|
|
PikaObj* obj = newRootObj("test", New_PikaStdLib_SysObj);
|
|
|
|
__platform_printf("BEGIN\r\n");
|
|
|
|
obj_runDirect(obj, "printttt('hello world')");
|
2022-03-22 09:43:19 +08:00
|
|
|
// char* sysOut = args_getSysOut(globals->list);
|
2022-03-22 09:56:23 +08:00
|
|
|
// int errCode = args_getErrorCode(globals->list);
|
2022-03-22 09:43:19 +08:00
|
|
|
// printf("sysout = %s\r\n", sysOut);
|
2022-04-30 21:17:19 +08:00
|
|
|
// ASSERT_EQ(1, strEqu("[error] runner: method no found.", sysOut));
|
2022-06-30 16:10:08 +08:00
|
|
|
EXPECT_STREQ(log_buff[4], "NameError: name 'printttt' is not defined\r\n");
|
2022-03-22 09:56:23 +08:00
|
|
|
// ASSERT_EQ(2, errCode);
|
2021-11-23 12:15:12 +08:00
|
|
|
// obj_deinit(globals);
|
2021-10-31 00:04:00 +08:00
|
|
|
obj_deinit(obj);
|
|
|
|
EXPECT_EQ(pikaMemNow(), 0);
|
|
|
|
}
|