def test_sclist2pylist(self): from runtime import sclist2pylist, build_list x = [1, 2, 3] assert x == sclist2pylist(build_list(x)) x = [1, 2, [3, 4]] assert x == sclist2pylist(build_list(x)) x = [[3, 4], [5, 6]] assert x == sclist2pylist(build_list(x)) x = [1] assert x == sclist2pylist(build_list(x)) x = [] assert x == sclist2pylist(build_list(x))
def __init__(self, proto, upvars, args): self.proto = proto self.insts = proto.insts self.args = args self.upvars = upvars self.to_be_forked = False self.localvars = [None] * proto.maxLocalvars argn = len(args) argc = proto.argc if proto.isVararg: if argn >= argc: self.localvars[:argc] = args[:argc] self.varargs = build_list(args[argc:]) else: raise VMException("Expect equal or more than %s arguments, got %s" % (argc, argn)) else: if argn == argc: self.localvars[:argc] = args[:] else: raise VMException("Expect %s arguments, got %s" % (argc, argn)) self.stack = []
def newList(*args): return [runtime.build_list(args)]