mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
add test for from _ import _ as _
This commit is contained in:
parent
f03208c530
commit
f167445b1f
@ -2551,6 +2551,7 @@ TEST(parser, multiLine_import) {
|
||||
char* lines =(char *)
|
||||
"import TEE\n"
|
||||
"from EE import C\n"
|
||||
"from PikaStdLib import MemChecker as MC\n"
|
||||
"while true:\n"
|
||||
" rgb.flow()\n"
|
||||
" if false:\n"
|
||||
@ -2566,6 +2567,9 @@ TEST(parser, multiLine_import) {
|
||||
"0 REF EE.C\n"
|
||||
"0 OUT C\n"
|
||||
"B0\n"
|
||||
"0 REF PikaStdLib.MemChecker\n"
|
||||
"0 OUT MC\n"
|
||||
"B0\n"
|
||||
"0 REF true\n"
|
||||
"0 JEZ 2\n"
|
||||
"B1\n"
|
||||
|
@ -1363,6 +1363,7 @@ static char* Parser_PreProcess_from(Args* buffs_p, char* line) {
|
||||
}
|
||||
char* class = NULL;
|
||||
char* module = NULL;
|
||||
char* alias = NULL;
|
||||
char* stmt = line + 5;
|
||||
ParserState_forEachToken(ps, stmt) {
|
||||
ParserState_iterStart(&ps);
|
||||
@ -1372,6 +1373,9 @@ static char* Parser_PreProcess_from(Args* buffs_p, char* line) {
|
||||
if (strEqu(ps.token1.pyload, " import ")) {
|
||||
class = strsCopy(&buffs, ps.token2.pyload);
|
||||
}
|
||||
if (strEqu(ps.token1.pyload, " as ")) {
|
||||
alias = strsCopy(&buffs, ps.token2.pyload);
|
||||
}
|
||||
ParserState_iterEnd(&ps);
|
||||
}
|
||||
ParserState_deinit(&ps);
|
||||
@ -1386,7 +1390,11 @@ static char* Parser_PreProcess_from(Args* buffs_p, char* line) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
line_out = strsFormat(&buffs, PIKA_LINE_BUFF_SIZE, "%s = %s.%s", class,
|
||||
if (NULL == alias){
|
||||
alias = class;
|
||||
}
|
||||
|
||||
line_out = strsFormat(&buffs, PIKA_LINE_BUFF_SIZE, "%s = %s.%s", alias,
|
||||
module, class);
|
||||
line_out = strsCopy(buffs_p, line_out);
|
||||
exit:
|
||||
|
Loading…
x
Reference in New Issue
Block a user