mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
fix built-in function print
This commit is contained in:
parent
f152db319c
commit
57a04ca87e
2
port/linux/.vscode/launch.json
vendored
2
port/linux/.vscode/launch.json
vendored
@ -11,7 +11,7 @@
|
||||
"program": "${workspaceFolder}/build/test/pikascript_test",
|
||||
// "program": "${workspaceFolder}/build/boot/demo06-pikamain/pikascript_demo06-pikamain",
|
||||
"args": [
|
||||
// "--gtest_filter=vm.getattr_native"
|
||||
"--gtest_filter=vm.dir_print_arg"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
|
@ -318,7 +318,11 @@ Arg* arg_toStrArg(Arg* arg) {
|
||||
strEqu(method_store->name, "tuple")) {
|
||||
pika_platform_snprintf(buff, PIKA_SPRINTF_BUFF_SIZE,
|
||||
"<class '%s'>", method_store->name);
|
||||
return arg_newStr(buff);
|
||||
}
|
||||
pika_platform_snprintf(buff, PIKA_SPRINTF_BUFF_SIZE,
|
||||
"<built-in function %s>",
|
||||
method_store->name);
|
||||
return arg_newStr(buff);
|
||||
}
|
||||
if (argType_isConstructor(type)) {
|
||||
@ -338,7 +342,7 @@ Arg* arg_toStrArg(Arg* arg) {
|
||||
}
|
||||
if (type == ARG_TYPE_OBJECT_META) {
|
||||
pika_platform_snprintf(buff, PIKA_SPRINTF_BUFF_SIZE,
|
||||
"<mate object at %p>", arg_getPtr(arg));
|
||||
"<meta object at %p>", arg_getPtr(arg));
|
||||
return arg_newStr(buff);
|
||||
}
|
||||
return NULL;
|
||||
|
@ -2711,6 +2711,25 @@ TEST(vm, type_fullfealure){
|
||||
obj_deinit(pikaMain);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
|
||||
TEST(vm, dir_print_arg){
|
||||
/* 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, "print(dir)\r\n");
|
||||
/* collect */
|
||||
/* assert */
|
||||
EXPECT_STREQ(log_buff[0], "<built-in function dir>\r\n");
|
||||
/* deinit */
|
||||
obj_deinit(pikaMain);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
TEST_END
|
Loading…
x
Reference in New Issue
Block a user