From f6b97e1f7a8e0135d31b289fcfebbf030ab2caec Mon Sep 17 00:00:00 2001 From: lyon Date: Sat, 17 Dec 2022 15:47:08 +0800 Subject: [PATCH] add test for def not in --- src/PikaVersion.h | 2 +- test/VM-test.cpp | 21 +++++++++++++++++++++ test/parse-test.cpp | 19 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/PikaVersion.h b/src/PikaVersion.h index fa1ddc4be..a22997e51 100644 --- a/src/PikaVersion.h +++ b/src/PikaVersion.h @@ -2,4 +2,4 @@ #define PIKA_VERSION_MINOR 11 #define PIKA_VERSION_MICRO 9 -#define PIKA_EDIT_TIME "2022/12/11 12:01:10" +#define PIKA_EDIT_TIME "2022/12/17 15:47:06" diff --git a/test/VM-test.cpp b/test/VM-test.cpp index 5d8300108..2575ed4ae 100644 --- a/test/VM-test.cpp +++ b/test/VM-test.cpp @@ -2419,6 +2419,27 @@ TEST(vm, issue_not_in) { EXPECT_EQ(pikaMemNow(), 0); } +TEST(vm, def_not_in) { + PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain); + extern unsigned char pikaModules_py_a[]; + obj_linkLibrary(pikaMain, pikaModules_py_a); + obj_run(pikaMain, + "t = ['hmac-md5', 'other']\n" + "def test(a=\"hmac-md5\"):\n" + " print(\"input:\", a)\n" + " print(\"table:\", t)\n" + " if a not in t:\n" + " print(\"a not in t\")\n" + " else:\n" + " print(\"a in t\")\n" + "test()\n"); + /* assert */ + EXPECT_STREQ(log_buff[0], "a in t\r\n"); + /* deinit */ + obj_deinit(pikaMain); + EXPECT_EQ(pikaMemNow(), 0); +} + #endif TEST_END \ No newline at end of file diff --git a/test/parse-test.cpp b/test/parse-test.cpp index dd8b24dac..a6b518b0a 100644 --- a/test/parse-test.cpp +++ b/test/parse-test.cpp @@ -5061,6 +5061,25 @@ TEST(parser, not_in) { EXPECT_EQ(pikaMemNow(), 0); } +// TEST(parser, def_not_in) { +// pikaMemInfo.heapUsedMax = 0; +// Args* buffs = New_strBuff(); +// char* lines = +// "def test(a=\"hmac-md5\"):\n" +// " print(\"input:\",a)\n" +// " print(\"table:\"t )\n" +// " if a not in t:\n" +// " print(\"a not in t\")else:\n" +// " print(\"a in t\")\n" +// "test()\n"; +// printf("%s\r\n", lines); +// char* pikaAsm = Parser_linesToAsm(buffs, lines); +// printf("%s", pikaAsm); +// EXPECT_STREQ(pikaAsm, ""); +// args_deinit(buffs); +// EXPECT_EQ(pikaMemNow(), 0); +// } + #endif TEST_END \ No newline at end of file