mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-24 13:30:18 +00:00
...
This commit is contained in:
parent
81cf28f685
commit
af58396b04
@ -878,7 +878,7 @@ void init_builtins(VM* _vm) {
|
|||||||
_vm->bind_constructor<-1>(_vm->_t(VM::tp_tuple), [](VM* vm, ArgsView args) {
|
_vm->bind_constructor<-1>(_vm->_t(VM::tp_tuple), [](VM* vm, ArgsView args) {
|
||||||
if(args.size() == 1+0) return VAR(Tuple(0));
|
if(args.size() == 1+0) return VAR(Tuple(0));
|
||||||
if(args.size() == 1+1){
|
if(args.size() == 1+1){
|
||||||
List list = CAST(List, vm->py_list(args[1]));
|
List list(CAST(List, vm->py_list(args[1])));
|
||||||
return VAR(Tuple(std::move(list)));
|
return VAR(Tuple(std::move(list)));
|
||||||
}
|
}
|
||||||
vm->TypeError("tuple() takes at most 1 argument");
|
vm->TypeError("tuple() takes at most 1 argument");
|
||||||
|
|||||||
@ -245,21 +245,11 @@ except:
|
|||||||
# #####: 565: return VAR(self.index(sub));
|
# #####: 565: return VAR(self.index(sub));
|
||||||
# -: 566: });
|
# -: 566: });
|
||||||
# test str.find:
|
# test str.find:
|
||||||
assert type('25363546'.find('63')) is int
|
assert '25363546'.find('63') == 3
|
||||||
assert type('25363546'.find('err')) is int
|
assert '25363546'.find('err') == -1
|
||||||
|
|
||||||
|
|
||||||
# /************ list ************/
|
# /************ list ************/
|
||||||
# 未完全测试准确性-----------------------------------------------
|
|
||||||
# 174: 615: _vm->bind_constructor<-1>("list", [](VM* vm, ArgsView args) {
|
|
||||||
# 29: 616: if(args.size() == 1+0) return VAR(List());
|
|
||||||
# 29: 617: if(args.size() == 1+1){
|
|
||||||
# 29: 618: return vm->py_list(args[1]);
|
|
||||||
# -: 619: }
|
|
||||||
# #####: 620: vm->TypeError("list() takes 0 or 1 arguments");
|
|
||||||
# #####: 621: return vm->None;
|
|
||||||
# 29: 622: });
|
|
||||||
# test list:
|
|
||||||
try:
|
try:
|
||||||
list(1,2)
|
list(1,2)
|
||||||
print('未能拦截错误, 在测试 list')
|
print('未能拦截错误, 在测试 list')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user