1.1 --- a/docs/concepts.txt Sun May 31 18:44:40 2009 +0200 1.2 +++ b/docs/concepts.txt Mon Jun 01 02:41:57 2009 +0200 1.3 @@ -399,6 +399,26 @@ 1.4 g 1 2 3 1.5 h 1 2 1.6 1.7 +Confusion can occur when functions are adopted as methods, since the context 1.8 +then occupies the first slot in the invocation frame: 1.9 + 1.10 + def f(x, y, z): 1.11 + pass 1.12 + 1.13 + f(x=1, y=2, z=3) -> f(<context>, 1, 2, 3) 1.14 + -> f(1, 2, 3) 1.15 + 1.16 + class C: 1.17 + f = f 1.18 + 1.19 + def g(x, y, z): 1.20 + pass 1.21 + 1.22 + c = C() 1.23 + 1.24 + c.f(y=2, z=3) -> f(<context>, 2, 3) 1.25 + c.g(y=2, z=3) -> C.g(<context>, 2, 3) 1.26 + 1.27 Just as with parameter tables, a displacement list can be prepared from a 1.28 parameter table: 1.29
2.1 --- a/docs/exceptions.txt Sun May 31 18:44:40 2009 +0200 2.2 +++ b/docs/exceptions.txt Mon Jun 01 02:41:57 2009 +0200 2.3 @@ -9,6 +9,19 @@ 2.4 is raised in any handling of the exception, or upon exit of a handler where 2.5 the active exception has been caught (thus resetting the active exception). 2.6 2.7 +Instructions 2.8 +------------ 2.9 + 2.10 +StoreException records the current value reference using the exception 2.11 +register. 2.12 + 2.13 +LoadException obtains the current exception and puts it in the value register. 2.14 + 2.15 +CheckException checks the current exception against a class referenced by the 2.16 +current value. 2.17 + 2.18 +ClearException resets the exception register. 2.19 + 2.20 Handlers 2.21 ======== 2.22
3.1 --- a/docs/invocation.txt Sun May 31 18:44:40 2009 +0200 3.2 +++ b/docs/invocation.txt Mon Jun 01 02:41:57 2009 +0200 3.3 @@ -163,6 +163,23 @@ 3.4 3.5 Approach #2 - add arguments, add defaults while checking frame 3.6 3.7 +Defaults for lambda functions: 3.8 + 3.9 + f = lambda x, y=default: ... 3.10 + 3.11 + Defines instance of f with method: 3.12 + 3.13 + def <lambda>(<context>, x, y=default): 3.14 + ... 3.15 + 3.16 + Where default is attribute #1. 3.17 + 3.18 + f(obj) # f not known at compile-time 3.19 + 3.20 + f -> f 3.21 + -> load context for argument #1 (f, since an instance is referenced) 3.22 + obj -> argument #2 3.23 + 3.24 Functions as methods: 3.25 3.26 def f(x, y, z): ...
4.1 --- a/micropython/__init__.py Sun May 31 18:44:40 2009 +0200 4.2 +++ b/micropython/__init__.py Mon Jun 01 02:41:57 2009 +0200 4.3 @@ -259,10 +259,15 @@ 4.4 if not with_builtins and item.module.name == "__builtins__": 4.5 item.code_location = item.full_name() 4.6 4.7 - # Skip any defaults. 4.8 + # Skip any defaults for named functions. 4.9 + 4.10 + elif item.name is not None: 4.11 + item.code_location = pos + len(item.defaults) 4.12 + 4.13 + # Skip any defaults for lambda functions. 4.14 4.15 else: 4.16 - item.code_location = pos + len(item.defaults) 4.17 + item.code_location = pos 4.18 4.19 current_function = item 4.20 4.21 @@ -307,7 +312,8 @@ 4.22 # Check the code location only where the code has been generated. 4.23 4.24 assert (not with_builtins and item.module.name == "__builtins__") or \ 4.25 - item.code_location == len(self.raw_code) + len(item.defaults) 4.26 + item.name is not None and item.code_location == len(self.raw_code) + len(item.defaults) or \ 4.27 + item.name is None and item.code_location == len(self.raw_code) 4.28 4.29 elif isinstance(item, micropython.data.Module): 4.30 assert item.location == len(self.raw_code) 4.31 @@ -743,23 +749,4 @@ 4.32 continue 4.33 module.set_module(submodule, self.add_module(module.name + "." + submodule)) 4.34 4.35 -# Convenience functions. 4.36 - 4.37 -def program(filename, path, requested_optimisations, verbose=0): 4.38 - 4.39 - """ 4.40 - Return the program object for the program specified by the given 'filename', 4.41 - module search 'path' and 'requested_optimisations'. 4.42 - """ 4.43 - 4.44 - i = micropython.Importer(path, verbose, requested_optimisations) 4.45 - p = micropython.Program(i, requested_optimisations) 4.46 - 4.47 - i.load_from_file("lib/builtins.py", "__builtins__") 4.48 - 4.49 - if filename is not None: 4.50 - i.load_from_file(filename) 4.51 - 4.52 - return p 4.53 - 4.54 # vim: tabstop=4 expandtab shiftwidth=4
5.1 --- a/micropython/ast.py Sun May 31 18:44:40 2009 +0200 5.2 +++ b/micropython/ast.py Mon Jun 01 02:41:57 2009 +0200 5.3 @@ -170,7 +170,7 @@ 5.4 5.5 # Make an object and store it in the unused first slot. 5.6 5.7 - self.make_object(cls, len(cls.instance_attributes())) 5.8 + self.make_instance(cls, len(cls.instance_attributes())) 5.9 self.new_op(StoreTemp(0)) 5.10 5.11 # Invoke the appropriate initialiser. 5.12 @@ -596,7 +596,7 @@ 5.13 fn.body_block = self.new_block() 5.14 check_block = self.new_block() 5.15 5.16 - self._generateFunctionContextTest(node, check_block, fn.body_block) 5.17 + self._generateFunctionContextTest(node, check_block) 5.18 5.19 # Check the number of parameters and defaults. 5.20 5.21 @@ -604,7 +604,8 @@ 5.22 5.23 self.new_op(CheckFrame((nparams, ndefaults, fn.has_star))) 5.24 if ndefaults > 0: 5.25 - self.new_op(FillDefaults((nparams, ndefaults, fn))) 5.26 + self.new_op(LoadFunction(fn)) 5.27 + self.new_op(FillDefaults((nparams, ndefaults))) 5.28 5.29 # Produce the body. 5.30 5.31 @@ -673,7 +674,7 @@ 5.32 fn.body_block = self.new_block() 5.33 check_block = self.new_block() 5.34 5.35 - self._generateFunctionContextTest(node, check_block, fn.body_block) 5.36 + self._generateFunctionContextTest(node, check_block) 5.37 5.38 # Check the number of parameters and defaults. 5.39 5.40 @@ -681,7 +682,8 @@ 5.41 5.42 self.new_op(CheckFrame((nparams, ndefaults, fn.has_star))) 5.43 if ndefaults > 0: 5.44 - self.new_op(FillDefaults((nparams, ndefaults, fn))) 5.45 + self.new_op(LoadTemp(0)) # context provides storage 5.46 + self.new_op(FillDefaults((nparams, ndefaults))) 5.47 5.48 # Produce the body. 5.49
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/micropython/cmd.py Mon Jun 01 02:41:57 2009 +0200 6.3 @@ -0,0 +1,54 @@ 6.4 +#!/usr/bin/env python 6.5 + 6.6 +""" 6.7 +Command option processing and other utilities for compiling and testing 6.8 +programs. 6.9 +""" 6.10 + 6.11 +import micropython 6.12 + 6.13 +def parse_optimisations(args): 6.14 + 6.15 + "Parse 'args' for optimisation flags." 6.16 + 6.17 + if "-omax" in args: 6.18 + requested_optimisations = micropython.Program.supported_optimisations 6.19 + else: 6.20 + requested_optimisations = [] 6.21 + for arg in args: 6.22 + if arg.startswith("-o"): 6.23 + for arg_part in arg[2:].split(","): 6.24 + requested_optimisations.append(arg_part) 6.25 + 6.26 + return requested_optimisations 6.27 + 6.28 +def program(filename, path, requested_optimisations, verbose=0): 6.29 + 6.30 + """ 6.31 + Return the program object for the program specified by the given 'filename', 6.32 + module search 'path' and 'requested_optimisations'. 6.33 + """ 6.34 + 6.35 + i = micropython.Importer(path, verbose, requested_optimisations) 6.36 + p = micropython.Program(i, requested_optimisations) 6.37 + 6.38 + i.load_from_file("lib/builtins.py", "__builtins__") 6.39 + 6.40 + if filename is not None: 6.41 + i.load_from_file(filename) 6.42 + 6.43 + return p 6.44 + 6.45 +# Convenience functions. 6.46 + 6.47 +def get_program(filename, path, args): 6.48 + 6.49 + """ 6.50 + Return the program object for the program specified by the given 'filename', 6.51 + module search 'path' and command 'args'. 6.52 + """ 6.53 + 6.54 + requested_optimisations = parse_optimisations(args) 6.55 + return program(filename, path, requested_optimisations, "-v" in args) 6.56 + 6.57 +# vim: tabstop=4 expandtab shiftwidth=4
7.1 --- a/micropython/data.py Sun May 31 18:44:40 2009 +0200 7.2 +++ b/micropython/data.py Mon Jun 01 02:41:57 2009 +0200 7.3 @@ -899,6 +899,11 @@ 7.4 self.astnode = node 7.5 self.referenced = 0 7.6 7.7 + # For lambda functions with defaults, add a context argument. 7.8 + 7.9 + if name is None and defaults: 7.10 + self.argnames.insert(0, "<context>") 7.11 + 7.12 # Initialise the positional names. 7.13 7.14 self.positional_names = self.argnames[:] 7.15 @@ -970,7 +975,7 @@ 7.16 objtable.get_index("__builtins__.function"), # is instance 7.17 self.code_location, 7.18 "__builtins__.function", 7.19 - len(self.defaults) + 1, # size 7.20 + len(self.defaults) + 1, # size (not accurate for lambda functions before instantiation) 7.21 paramtable.as_list().get_code(self.full_name()) # funccode 7.22 ) 7.23 ]
8.1 --- a/micropython/inspect.py Sun May 31 18:44:40 2009 +0200 8.2 +++ b/micropython/inspect.py Mon Jun 01 02:41:57 2009 +0200 8.3 @@ -321,6 +321,8 @@ 8.4 None. 8.5 """ 8.6 8.7 + # Define the function object. 8.8 + 8.9 function = Function( 8.10 name, 8.11 self.get_parent(), 8.12 @@ -332,6 +334,8 @@ 8.13 node 8.14 ) 8.15 8.16 + self.add_object(function, any_scope=1) 8.17 + 8.18 # Make a back reference from the node for code generation. 8.19 8.20 node.unit = function 8.21 @@ -377,7 +381,6 @@ 8.22 if node.defaults: 8.23 return Instance() # indicates no known target 8.24 8.25 - self.add_object(function, any_scope=1) 8.26 return function 8.27 8.28 # Specific handler methods.
9.1 --- a/micropython/opt.py Sun May 31 18:44:40 2009 +0200 9.2 +++ b/micropython/opt.py Mon Jun 01 02:41:57 2009 +0200 9.3 @@ -193,7 +193,8 @@ 9.4 StoreAddressContext, # as the context 9.5 LoadCallable, 9.6 TestIdentity, TestIdentityAddress, CheckSelf, # as one of the operands 9.7 - CheckException, CheckFrame, MakeObject, 9.8 + CheckException, CheckFrame, FillDefaults, 9.9 + MakeInstance, 9.10 CheckContext, CheckClassContext, 9.11 LoadContext # as the object providing the result 9.12 ))
10.1 --- a/micropython/program.py Sun May 31 18:44:40 2009 +0200 10.2 +++ b/micropython/program.py Mon Jun 01 02:41:57 2009 +0200 10.3 @@ -36,6 +36,9 @@ 10.4 def with_size(self, size): 10.5 return DataObject(self.classcode, self.attrcode, self.codeaddr, self.name, size, self.funccode) 10.6 10.7 + def with_callable(self, codeaddr): 10.8 + return DataObject(self.classcode, self.attrcode, codeaddr, self.name, self.size, self.funccode) 10.9 + 10.10 def __repr__(self): 10.11 return "%r # %s" % ( 10.12 (self.classcode, self.attrcode, self.codeaddr, self.funccode, self.size), self.name
11.1 --- a/micropython/rsvp.py Sun May 31 18:44:40 2009 +0200 11.2 +++ b/micropython/rsvp.py Mon Jun 01 02:41:57 2009 +0200 11.3 @@ -173,7 +173,7 @@ 11.4 class LoadAddressContextCond(Address): 11.5 """Load the current value from the given fixed attribute address, only using the current value as 11.6 context if the attribute is compatible.""" 11.7 -class MakeObject(Immediate): "Make a new object. There isn't a complementary DropObject." 11.8 +class MakeInstance(Immediate): "Make a new instance." 11.9 11.10 # Access to address-relative data. 11.11 11.12 @@ -249,7 +249,7 @@ 11.13 LoadAddress, LoadAddressContext, LoadAddressContextCond, 11.14 LoadAttr, LoadAttrIndex, LoadAttrIndexContextCond, 11.15 LoadCallable, LoadContext, LoadResult, 11.16 - LoadException, MakeObject 11.17 + LoadException, MakeInstance 11.18 ) 11.19 11.20 # vim: tabstop=4 expandtab shiftwidth=4
12.1 --- a/micropython/trans.py Sun May 31 18:44:40 2009 +0200 12.2 +++ b/micropython/trans.py Mon Jun 01 02:41:57 2009 +0200 12.3 @@ -30,19 +30,20 @@ 12.4 12.5 # Allocation-related methods. 12.6 12.7 - def make_object(self, cls, n): 12.8 + def make_instance(self, cls, n): 12.9 12.10 """ 12.11 - Request a new object with the given class 'cls' and with 'n' attributes. 12.12 + Request a new instance using the given class 'cls' and with 'n' 12.13 + attributes. 12.14 """ 12.15 12.16 # Load the class in order to locate the instance template. 12.17 12.18 self.new_op(LoadConst(cls)) 12.19 12.20 - # NOTE: Object headers are one location. 12.21 + # NOTE: Instance headers are one location. 12.22 12.23 - self.new_op(MakeObject(n + 1)) 12.24 + self.new_op(MakeInstance(n + 1)) 12.25 12.26 def make_exception(self, name, node): 12.27 12.28 @@ -50,7 +51,7 @@ 12.29 12.30 # NOTE: Reserving only one attribute. 12.31 12.32 - self.make_object(self.get_builtin_class(name, node), 1) 12.33 + self.make_instance(self.get_builtin_class(name, node), 1) 12.34 12.35 # Name-related methods. 12.36 12.37 @@ -247,7 +248,7 @@ 12.38 on the 'extend' instruction. 12.39 """ 12.40 12.41 - ntemp = self.max_temp_position + 2 # include space for instantiators to expand backwards 12.42 + ntemp = self.max_temp_position + 1 12.43 extend.attr = ntemp + node.unit.local_usage # NOTE: See get_code for similar code. 12.44 12.45 # Code writing methods. 12.46 @@ -842,7 +843,7 @@ 12.47 dynamic = function.name is None 12.48 12.49 if dynamic: 12.50 - self.make_object(self.get_builtin_class("function", function), len(attr_to_default)) 12.51 + self.make_instance(self.get_builtin_class("function", function), len(attr_to_default)) 12.52 temp = self.get_temp() 12.53 12.54 for attr, default in attr_to_default: 12.55 @@ -862,11 +863,11 @@ 12.56 else: 12.57 return None 12.58 12.59 - def _generateFunctionContextTest(self, node, check_block, body_block): 12.60 + def _generateFunctionContextTest(self, node, check_block): 12.61 12.62 """ 12.63 Generate code to test the context for 'node', jumping to 'check_block' 12.64 - and 'body_block' from this code. 12.65 + from this code. 12.66 """ 12.67 12.68 adjust_block = self.new_block() 12.69 @@ -1189,7 +1190,7 @@ 12.70 12.71 "Make a sequence of 'sequence_type' for the given program 'node'." 12.72 12.73 - self.make_object(self.get_builtin_class(sequence_type, node), len(node.nodes)) 12.74 + self.make_instance(self.get_builtin_class(sequence_type, node), len(node.nodes)) 12.75 temp = self.get_temp() 12.76 12.77 for i, n in enumerate(node.nodes):
13.1 --- a/rsvp.py Sun May 31 18:44:40 2009 +0200 13.2 +++ b/rsvp.py Mon Jun 01 02:41:57 2009 +0200 13.3 @@ -52,7 +52,6 @@ 13.4 current callable 13.5 """ 13.6 13.7 -from micropython.program import DataObject # for creating "nice" new objects 13.8 import operator 13.9 13.10 class IllegalInstruction(Exception): 13.11 @@ -432,7 +431,7 @@ 13.12 context = source_context 13.13 self.save(self.operand, (context, source_ref)) 13.14 13.15 - def MakeObject(self): 13.16 + def MakeInstance(self): 13.17 size = self.operand 13.18 context, ref = self.value 13.19 # NOTE: Referencing the instance template. 13.20 @@ -538,7 +537,7 @@ 13.21 context, ref = self.value 13.22 # NOTE: Should improve the representation and permit direct saving. 13.23 data = self.load(ref) 13.24 - self.save(ref, (data.classcode, data.attrcode) + self.callable) 13.25 + self.save(ref, data.with_callable(self.callable)) 13.26 13.27 def LoadContext(self): 13.28 context, ref = self.value 13.29 @@ -575,9 +574,8 @@ 13.30 return self.RaiseException() 13.31 13.32 def FillDefaults(self): 13.33 - # NOTE: Make the get_operand method of the instruction provide the 13.34 - # NOTE: function location. 13.35 - (nargs, ndefaults, fn) = self.operand 13.36 + context, ref = self.value 13.37 + (nargs, ndefaults) = self.operand 13.38 13.39 # The frame is actually installed as the locals. 13.40 13.41 @@ -590,7 +588,6 @@ 13.42 default = nlocals - (nargs - ndefaults) 13.43 self.frame_stack.extend([None] * (nargs - nlocals)) 13.44 pos = nlocals 13.45 - ref = fn.location 13.46 13.47 while pos < nargs: 13.48 self.frame_stack[frame + pos] = self.load(ref + default + 1) # skip header 13.49 @@ -914,6 +911,7 @@ 13.50 13.51 native_functions = { 13.52 "__builtins__.int.__add__" : builtins_int_add, 13.53 + "__builtins__.int.__radd__" : builtins_int_add, # NOTE: To be made distinct. 13.54 "__builtins__.int.__bool__" : builtins_int_bool, 13.55 "__builtins__.int.__neg__" : builtins_int_neg, 13.56 "__builtins__.int.__lt__" : builtins_int_lt,
14.1 --- a/test.py Sun May 31 18:44:40 2009 +0200 14.2 +++ b/test.py Mon Jun 01 02:41:57 2009 +0200 14.3 @@ -1,6 +1,6 @@ 14.4 #!/usr/bin/env python 14.5 14.6 -import micropython 14.7 +import micropython.cmd 14.8 from micropython.graph import get_graph 14.9 import rsvp 14.10 import sys 14.11 @@ -20,23 +20,6 @@ 14.12 for name, attr in obj.items(): 14.13 print name, attr 14.14 14.15 -# Command option processing. 14.16 - 14.17 -def parse_optimisations(args): 14.18 - 14.19 - "Parse 'args' for optimisation flags." 14.20 - 14.21 - if "-omax" in args: 14.22 - requested_optimisations = micropython.Program.supported_optimisations 14.23 - else: 14.24 - requested_optimisations = [] 14.25 - for arg in args: 14.26 - if arg.startswith("-o"): 14.27 - for arg_part in arg[2:].split(","): 14.28 - requested_optimisations.append(arg_part) 14.29 - 14.30 - return requested_optimisations 14.31 - 14.32 # Main program. 14.33 14.34 if __name__ == "__main__": 14.35 @@ -49,12 +32,10 @@ 14.36 else: 14.37 filename = None 14.38 14.39 - requested_optimisations = parse_optimisations(args) 14.40 - 14.41 # Make the program. 14.42 14.43 try: 14.44 - p = micropython.program(filename, path, requested_optimisations, "-v" in args) 14.45 + p = micropython.cmd.get_program(filename, path, args) 14.46 if filename is None: 14.47 print "Loading module micropython ..." 14.48 m = p.get_importer().load("micropython")
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/test_all.py Mon Jun 01 02:41:57 2009 +0200 15.3 @@ -0,0 +1,52 @@ 15.4 +#!/usr/bin/env python 15.5 + 15.6 +import micropython.cmd 15.7 +import rsvp 15.8 +import sys 15.9 +import os 15.10 +from glob import glob 15.11 + 15.12 +# Main program. 15.13 + 15.14 +if __name__ == "__main__": 15.15 + args = sys.argv[1:] 15.16 + path = sys.path[:] 15.17 + path.append("tests") 15.18 + 15.19 + # Process all tests. 15.20 + 15.21 + try: 15.22 + _f = args.index("-f") 15.23 + filenames = args[_f+1:] 15.24 + except ValueError: 15.25 + filenames = glob(os.path.join("tests", "*.py")) 15.26 + 15.27 + filenames.sort() 15.28 + 15.29 + results = [] 15.30 + 15.31 + for filename in filenames: 15.32 + print "Processing", filename 15.33 + 15.34 + try: 15.35 + p = micropython.cmd.get_program(filename, path, args) 15.36 + m = p.get_importer().get_module("__main__") 15.37 + 15.38 + # Report any errors. 15.39 + 15.40 + except micropython.ProcessingError, exc: 15.41 + print repr(exc) 15.42 + if "-tb" in args: 15.43 + raise 15.44 + 15.45 + else: 15.46 + rm = rsvp.machine(p) 15.47 + success = rm.test(m) 15.48 + print "Test successful?", success 15.49 + results.append((filename, success)) 15.50 + 15.51 + print 15.52 + for result in results: 15.53 + print result 15.54 + 15.55 +# vim: tabstop=4 expandtab shiftwidth=4
16.1 --- a/tests/attributes_class_bind_function_unbound.py Sun May 31 18:44:40 2009 +0200 16.2 +++ b/tests/attributes_class_bind_function_unbound.py Mon Jun 01 02:41:57 2009 +0200 16.3 @@ -11,6 +11,6 @@ 16.4 16.5 d = D() 16.6 q = d.e # unbound C.e 16.7 -result_321 = q(321) 16.8 +result_321 = q(C(), 321) 16.9 16.10 # vim: tabstop=4 expandtab shiftwidth=4
17.1 --- a/tests/attributes_class_bind_function_unbound_fake_self.py Sun May 31 18:44:40 2009 +0200 17.2 +++ b/tests/attributes_class_bind_function_unbound_fake_self.py Mon Jun 01 02:41:57 2009 +0200 17.3 @@ -11,6 +11,6 @@ 17.4 17.5 d = D() 17.6 q = d.e # unbound C.e 17.7 -result_321 = q(123, 321) 17.8 +result_321 = q(C(), 321) 17.9 17.10 # vim: tabstop=4 expandtab shiftwidth=4
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 18.2 +++ b/tests/attributes_instance_bind_function.py Mon Jun 01 02:41:57 2009 +0200 18.3 @@ -0,0 +1,14 @@ 18.4 +#!/usr/bin/env python 18.5 + 18.6 +def e(self, x): 18.7 + return x 18.8 + 18.9 +class C: 18.10 + def __init__(self, e): 18.11 + self.e = e 18.12 + 18.13 +c = C(e) 18.14 +p = c.e # unbound e 18.15 +result_321 = p(123, 321) 18.16 + 18.17 +# vim: tabstop=4 expandtab shiftwidth=4
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 19.2 +++ b/tests/call_func_dstar_parameter.py Mon Jun 01 02:41:57 2009 +0200 19.3 @@ -0,0 +1,14 @@ 19.4 +#!/usr/bin/env python 19.5 + 19.6 +def f(a, b, **c): 19.7 + return c 19.8 + 19.9 +r1 = f(1, 2, 3) 19.10 +r2 = f(1, b=2, c=3, d=4) 19.11 +r3 = f(c=3, b=2, a=1, d=4) 19.12 + 19.13 +g = f 19.14 + 19.15 +r4 = g(1, c=3, b=2, d=4) 19.16 + 19.17 +# vim: tabstop=4 expandtab shiftwidth=4
20.1 --- a/tests/call_func_keyword.py Sun May 31 18:44:40 2009 +0200 20.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 20.3 @@ -1,14 +0,0 @@ 20.4 -#!/usr/bin/env python 20.5 - 20.6 -def f(a, b, **c): 20.7 - return c 20.8 - 20.9 -r1 = f(1, 2, 3) 20.10 -r2 = f(1, b=2, c=3, d=4) 20.11 -r3 = f(c=3, b=2, a=1, d=4) 20.12 - 20.13 -g = f 20.14 - 20.15 -r4 = g(1, c=3, b=2, d=4) 20.16 - 20.17 -# vim: tabstop=4 expandtab shiftwidth=4
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 21.2 +++ b/tests/call_method_keywords.py Mon Jun 01 02:41:57 2009 +0200 21.3 @@ -0,0 +1,10 @@ 21.4 +#!/usr/bin/env python 21.5 + 21.6 +class C: 21.7 + def m(self, x): 21.8 + return x 21.9 + 21.10 +c = C() 21.11 +result_123 = c.m(x=123) 21.12 + 21.13 +# vim: tabstop=4 expandtab shiftwidth=4
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 22.2 +++ b/tests/failure/attributes_class_bind_function_unbound.py Mon Jun 01 02:41:57 2009 +0200 22.3 @@ -0,0 +1,16 @@ 22.4 +#!/usr/bin/env python 22.5 + 22.6 +def e(self, x): 22.7 + return x 22.8 + 22.9 +class C: 22.10 + e = e 22.11 + 22.12 +class D: 22.13 + e = C.e 22.14 + 22.15 +d = D() 22.16 +q = d.e # unbound C.e 22.17 +result_321 = q(321) 22.18 + 22.19 +# vim: tabstop=4 expandtab shiftwidth=4
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 23.2 +++ b/tests/failure/attributes_class_bind_function_unbound_fake_self.py Mon Jun 01 02:41:57 2009 +0200 23.3 @@ -0,0 +1,16 @@ 23.4 +#!/usr/bin/env python 23.5 + 23.6 +def e(self, x): 23.7 + return x 23.8 + 23.9 +class C: 23.10 + e = e 23.11 + 23.12 +class D: 23.13 + e = C.e 23.14 + 23.15 +d = D() 23.16 +q = d.e # unbound C.e 23.17 +result_321 = q(123, 321) 23.18 + 23.19 +# vim: tabstop=4 expandtab shiftwidth=4
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 24.2 +++ b/tests/failure/attributes_instance_bind_function.py Mon Jun 01 02:41:57 2009 +0200 24.3 @@ -0,0 +1,14 @@ 24.4 +#!/usr/bin/env python 24.5 + 24.6 +def e(self, x): 24.7 + return x 24.8 + 24.9 +class C: 24.10 + def __init__(self, e): 24.11 + self.e = e 24.12 + 24.13 +c = C(e) 24.14 +p = c.e # unbound e 24.15 +result_321 = p(321) 24.16 + 24.17 +# vim: tabstop=4 expandtab shiftwidth=4
25.1 --- a/tests/lambda.py Sun May 31 18:44:40 2009 +0200 25.2 +++ b/tests/lambda.py Mon Jun 01 02:41:57 2009 +0200 25.3 @@ -9,10 +9,10 @@ 25.4 def g(f, x): 25.5 return f(x) 25.6 25.7 -identity(1) 25.8 -add_2(1) 25.9 -g(identity, 1) 25.10 -g(add_2, 1) 25.11 -g(f(3), 1) 25.12 +result_1 = identity(1) 25.13 +result_3 = add_2(1) 25.14 +result2_1 = g(identity, 1) 25.15 +result2_3 = g(add_2, 1) 25.16 +result_4 = g(f(3), 1) 25.17 25.18 # vim: tabstop=4 expandtab shiftwidth=4