mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
fix queue overpop
This commit is contained in:
parent
76075564a2
commit
797607bccf
2
port/linux/.vscode/launch.json
vendored
2
port/linux/.vscode/launch.json
vendored
@ -21,7 +21,7 @@
|
||||
// "--gtest_filter=parser.__set__",
|
||||
// "--gtest_filter=parser.__get__",
|
||||
// "--gtest_filter=pikaMain.print_with_enter",
|
||||
"--gtest_filter=pikaMain.str_fun",
|
||||
// "--gtest_filter=pikaMain.str_fun",
|
||||
// "--gtest_filter=pikaMain.str_add",
|
||||
// "--gtest_filter=content*",
|
||||
// "--gtest_filter=pikaMain.print_in_def",
|
||||
|
@ -532,33 +532,33 @@ TEST(pikaMain, for_in_dict) {
|
||||
}
|
||||
|
||||
|
||||
// TEST(pikaMain, str_add) {
|
||||
// /* init */
|
||||
// pikaMemInfo.heapUsedMax = 0;
|
||||
// PikaObj* pikaMain = newRootObj((char*)"pikaMain", New_PikaMain);
|
||||
// /* run */
|
||||
// obj_run(pikaMain, (char*)
|
||||
// "a = 'a'\n"
|
||||
// "b = 'b'\n"
|
||||
// "c = a + b\n"
|
||||
// "d = 1\n"
|
||||
// "e = 1.2\n"
|
||||
// "g = c + str(d)\n"
|
||||
// "h = c + str(d) + str(e)\n"
|
||||
// "\n"
|
||||
// );
|
||||
// /* collect */
|
||||
// char* c = obj_getStr(pikaMain, (char*)"c");
|
||||
// char* g = obj_getStr(pikaMain, (char*)"g");
|
||||
// char* h = obj_getStr(pikaMain, (char*)"h");
|
||||
// /* assert */
|
||||
// EXPECT_STREQ(c, (char*)"ab");
|
||||
// EXPECT_STREQ(g, (char*)"ab1");
|
||||
// EXPECT_STREQ(h, (char*)"ab11.200000");
|
||||
// /* deinit */
|
||||
// obj_deinit(pikaMain);
|
||||
// EXPECT_EQ(pikaMemNow(), 0);
|
||||
// }
|
||||
TEST(pikaMain, str_add) {
|
||||
/* init */
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj((char*)"pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
obj_run(pikaMain, (char*)
|
||||
"a = 'a'\n"
|
||||
"b = 'b'\n"
|
||||
"c = a + b\n"
|
||||
"d = 1\n"
|
||||
"e = 1.2\n"
|
||||
"g = c + str(d)\n"
|
||||
"h = c + str(d) + str(e)\n"
|
||||
"\n"
|
||||
);
|
||||
/* collect */
|
||||
char* c = obj_getStr(pikaMain, (char*)"c");
|
||||
char* g = obj_getStr(pikaMain, (char*)"g");
|
||||
char* h = obj_getStr(pikaMain, (char*)"h");
|
||||
/* assert */
|
||||
EXPECT_STREQ(c, (char*)"ab");
|
||||
EXPECT_STREQ(g, (char*)"ab1");
|
||||
EXPECT_STREQ(h, (char*)"ab11.200000");
|
||||
/* deinit */
|
||||
obj_deinit(pikaMain);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(pikaMain, str_add_print) {
|
||||
/* init */
|
||||
|
@ -26,8 +26,8 @@
|
||||
*/
|
||||
|
||||
#include "dataQueue.h"
|
||||
#include "dataArgs.h"
|
||||
#include "PikaPlatform.h"
|
||||
#include "dataArgs.h"
|
||||
|
||||
Queue* New_queue(void) {
|
||||
Args* args = New_args(NULL);
|
||||
@ -55,7 +55,11 @@ int32_t queue_pushArg(Queue* queue, Arg* arg) {
|
||||
|
||||
Arg* queue_popArg(Queue* queue) {
|
||||
Args* args = queue;
|
||||
uint64_t top = args_getInt(args, "__t");
|
||||
uint64_t bottom = args_getInt(args, "__b");
|
||||
if (top - bottom < 1) {
|
||||
return NULL;
|
||||
}
|
||||
/* add bottom */
|
||||
args_setInt(args, "__b", bottom + 1);
|
||||
char buff[11];
|
||||
|
Loading…
x
Reference in New Issue
Block a user