diff --git a/src/pocketpy.cpp b/src/pocketpy.cpp index f36730a7..863f02dc 100644 --- a/src/pocketpy.cpp +++ b/src/pocketpy.cpp @@ -878,7 +878,7 @@ void init_builtins(VM* _vm) { _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+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))); } vm->TypeError("tuple() takes at most 1 argument"); diff --git a/tests/99_builtin_func.py b/tests/99_builtin_func.py index fb88ca80..abafd19d 100644 --- a/tests/99_builtin_func.py +++ b/tests/99_builtin_func.py @@ -245,21 +245,11 @@ except: # #####: 565: return VAR(self.index(sub)); # -: 566: }); # test str.find: -assert type('25363546'.find('63')) is int -assert type('25363546'.find('err')) is int +assert '25363546'.find('63') == 3 +assert '25363546'.find('err') == -1 # /************ 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: list(1,2) print('未能拦截错误, 在测试 list')