pikapython/port/linux/test/sysObj-test.cpp
李昂 6acc0f9ecd !25 support format output for print()
* test for format with tuple is ok
* 'format'%var is ok (tuple var is not ok)
* rename _cformat to cformat()
* optimize the memory usage of format_list
* add string-test.cpp
* cformat() is ok
* fix variable par load issue
* use test_common.h
* use test_common to simplify the gtest case
* Merge branch 'master' into dev
* fix float->double for bytecodegen
* update to /package
* Use double in C for float in python
2022-06-14 03:20:17 +00:00

32 lines
1.1 KiB
C

#include "test_common.h"
TEST(sysObj, print) {
PikaObj* obj = newRootObj("test", New_PikaStdLib_SysObj);
VMParameters* globals = obj_runDirect(obj, "print('hello world')");
// char* sysOut = args_getSysOut(globals->list);
int errCode = args_getErrorCode(globals->list);
// printf("sysout = %s\r\n", sysOut);
EXPECT_STREQ(log_buff[0], "hello world\r\n");
// ASSERT_STREQ("hello world", sysOut);
ASSERT_EQ(0, errCode);
// obj_deinit(globals);
obj_deinit(obj);
EXPECT_EQ(pikaMemNow(), 0);
}
TEST(sysObj, noMethod) {
PikaObj* obj = newRootObj("test", New_PikaStdLib_SysObj);
__platform_printf("BEGIN\r\n");
obj_runDirect(obj, "printttt('hello world')");
// char* sysOut = args_getSysOut(globals->list);
// int errCode = args_getErrorCode(globals->list);
// printf("sysout = %s\r\n", sysOut);
// ASSERT_EQ(1, strEqu("[error] runner: method no found.", sysOut));
EXPECT_STREQ(log_buff[4],
"NameError: name 'printttt' is not defined\r\n");
// ASSERT_EQ(2, errCode);
// obj_deinit(globals);
obj_deinit(obj);
EXPECT_EQ(pikaMemNow(), 0);
}