mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
support pass
support pass
This commit is contained in:
parent
d3026c7c99
commit
db54438caf
@ -1666,3 +1666,27 @@ TEST(vm, exit_fn) {
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(vm, pass_) {
|
||||
/* 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,
|
||||
"pass\n"
|
||||
"def testpass():\n"
|
||||
" pass\n"
|
||||
"for i in range(10):\n"
|
||||
" pass\n"
|
||||
"testpass()\n"
|
||||
"print('after pass')\n");
|
||||
/* collect */
|
||||
/* assert */
|
||||
EXPECT_STREQ(log_buff[0], "after pass\r\n");
|
||||
/* deinit */
|
||||
obj_deinit(pikaMain);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
@ -4270,4 +4270,45 @@ TEST(parser, for_multi) {
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(parser, pass_) {
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines =
|
||||
"pass\n"
|
||||
"def testpass():\n"
|
||||
" pass\n"
|
||||
"for i in range(10):\n"
|
||||
" pass\n";
|
||||
__platform_printf("%s\n", lines);
|
||||
char* pikaAsm = Parser_linesToAsm(buffs, lines);
|
||||
__platform_printf("%s", pikaAsm);
|
||||
EXPECT_STREQ(pikaAsm,
|
||||
"B0\n"
|
||||
"B0\n"
|
||||
"0 DEF testpass()\n"
|
||||
"0 JMP 1\n"
|
||||
"B1\n"
|
||||
"B1\n"
|
||||
"0 RET \n"
|
||||
"B0\n"
|
||||
"2 NUM 10\n"
|
||||
"1 RUN range\n"
|
||||
"0 RUN iter\n"
|
||||
"0 OUT $l0\n"
|
||||
"B0\n"
|
||||
"0 RUN $l0.__next__\n"
|
||||
"0 OUT i\n"
|
||||
"0 EST i\n"
|
||||
"0 JEZ 2\n"
|
||||
"B1\n"
|
||||
"B0\n"
|
||||
"0 JMP -1\n"
|
||||
"B0\n"
|
||||
"0 DEL $l0\n"
|
||||
"B0\n");
|
||||
|
||||
args_deinit(buffs);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,3 +1,3 @@
|
||||
MajorVersion = "1"
|
||||
MinorVersion = "10"
|
||||
MicroVersion = "8"
|
||||
MicroVersion = "9"
|
||||
|
@ -226,6 +226,11 @@ static enum StmtType Lexer_matchStmtType(char* right) {
|
||||
if (strEqu(cs.token1.pyload, "...")) {
|
||||
goto iter_continue;
|
||||
}
|
||||
|
||||
if (strEqu(cs.token1.pyload, "pass")){
|
||||
goto iter_continue;
|
||||
}
|
||||
|
||||
if (strIsStartWith(cs.token1.pyload, ".")) {
|
||||
if (cs.iter_index != 1) {
|
||||
is_get_chain = PIKA_TRUE;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#define PIKA_VERSION_MAJOR 1
|
||||
#define PIKA_VERSION_MINOR 10
|
||||
#define PIKA_VERSION_MICRO 8
|
||||
#define PIKA_VERSION_MICRO 9
|
||||
|
||||
#define PIKA_EDIT_TIME "2022/09/09 13:10:15"
|
||||
#define PIKA_EDIT_TIME "2022/09/15 18:43:26"
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user