mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
support in
op for **kw
This commit is contained in:
parent
2d599664a3
commit
13bfc829aa
12
examples/builtins/kw.py
Normal file
12
examples/builtins/kw.py
Normal file
@ -0,0 +1,12 @@
|
||||
def test_kw(**kw):
|
||||
if 'a' in kw:
|
||||
return kw['a']
|
||||
if 'b' in kw:
|
||||
return kw['b']
|
||||
|
||||
a = test_kw(a=1)
|
||||
b = test_kw(b=2)
|
||||
assert a == 1
|
||||
assert b == 2
|
||||
|
||||
print('PASS')
|
@ -189,16 +189,9 @@ int PikaStdData_dict_keys___len__(PikaObj* self) {
|
||||
}
|
||||
|
||||
int dict_contains(PikaDict* dict, Arg* key) {
|
||||
int i = 0;
|
||||
while (PIKA_TRUE) {
|
||||
Arg* item = args_getArgByIndex(_OBJ2KEYS(dict), i);
|
||||
if (NULL == item) {
|
||||
break;
|
||||
}
|
||||
if (arg_isEqual(item, key)) {
|
||||
return PIKA_TRUE;
|
||||
}
|
||||
i++;
|
||||
Hash hash = hash_time33(arg_getStr(key));
|
||||
if (args_isArgExist_hash(_OBJ2DICT(dict), hash)) {
|
||||
return pika_true;
|
||||
}
|
||||
return pika_false;
|
||||
}
|
||||
|
2
port/linux/.vscode/launch.json
vendored
2
port/linux/.vscode/launch.json
vendored
@ -12,7 +12,7 @@
|
||||
// "program": "${workspaceFolder}/build/boot/demo06-pikamain/pikascript_demo06-pikamain",
|
||||
"args": [
|
||||
// "--gtest_filter=vm.keyword_2"
|
||||
"--gtest_filter=builtin.repl_mode"
|
||||
// "--gtest_filter=builtin.kw"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
|
@ -189,16 +189,9 @@ int PikaStdData_dict_keys___len__(PikaObj* self) {
|
||||
}
|
||||
|
||||
int dict_contains(PikaDict* dict, Arg* key) {
|
||||
int i = 0;
|
||||
while (PIKA_TRUE) {
|
||||
Arg* item = args_getArgByIndex(_OBJ2KEYS(dict), i);
|
||||
if (NULL == item) {
|
||||
break;
|
||||
}
|
||||
if (arg_isEqual(item, key)) {
|
||||
return PIKA_TRUE;
|
||||
}
|
||||
i++;
|
||||
Hash hash = hash_time33(arg_getStr(key));
|
||||
if (args_isArgExist_hash(_OBJ2DICT(dict), hash)) {
|
||||
return pika_true;
|
||||
}
|
||||
return pika_false;
|
||||
}
|
||||
|
12
port/linux/test/python/builtins/kw.py
Normal file
12
port/linux/test/python/builtins/kw.py
Normal file
@ -0,0 +1,12 @@
|
||||
def test_kw(**kw):
|
||||
if 'a' in kw:
|
||||
return kw['a']
|
||||
if 'b' in kw:
|
||||
return kw['b']
|
||||
|
||||
a = test_kw(a=1)
|
||||
b = test_kw(b=2)
|
||||
assert a == 1
|
||||
assert b == 2
|
||||
|
||||
print('PASS')
|
@ -2,4 +2,4 @@
|
||||
#define PIKA_VERSION_MINOR 12
|
||||
#define PIKA_VERSION_MICRO 5
|
||||
|
||||
#define PIKA_EDIT_TIME "2023/09/07 14:46:48"
|
||||
#define PIKA_EDIT_TIME "2023/09/10 10:22:49"
|
||||
|
Loading…
x
Reference in New Issue
Block a user