diff --git a/port/linux/.vscode/launch.json b/port/linux/.vscode/launch.json index 3547a7830..af2c7f8b8 100644 --- a/port/linux/.vscode/launch.json +++ b/port/linux/.vscode/launch.json @@ -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}", diff --git a/src/dataArg.c b/src/dataArg.c index 568dce0d5..2593d20d8 100644 --- a/src/dataArg.c +++ b/src/dataArg.c @@ -318,7 +318,11 @@ Arg* arg_toStrArg(Arg* arg) { strEqu(method_store->name, "tuple")) { pika_platform_snprintf(buff, PIKA_SPRINTF_BUFF_SIZE, "", method_store->name); + return arg_newStr(buff); } + pika_platform_snprintf(buff, PIKA_SPRINTF_BUFF_SIZE, + "", + 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, - "", arg_getPtr(arg)); + "", arg_getPtr(arg)); return arg_newStr(buff); } return NULL; diff --git a/test/VM-test.cpp b/test/VM-test.cpp index 1d1223213..befc6cc05 100644 --- a/test/VM-test.cpp +++ b/test/VM-test.cpp @@ -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], "\r\n"); + /* deinit */ + obj_deinit(pikaMain); + EXPECT_EQ(pikaMemNow(), 0); +} + #endif TEST_END \ No newline at end of file