Lichen

tests/contexts.py

1038:e3d77b4d9fa8
5 months ago Paul Boddie Merged changes from the trailing-data branch. value-replacement
     1 class C:     2     l = [2, 4, 6, 8, 10]     3     s = "test"     4     def __init__(self, x):     5         self.x = x     6         self.y = 3     7         self.z = "zebra libre"     8     def __len__(self):     9         return len(self.z)    10     11 c = C([1])    12 x = c.x    13 f = c.x.__len__    14 print c             # <__main__.C instance>    15 print x             # [1]    16 print f             # __builtins__.list.list.__len__    17 print f()           # 1    18     19 y = c.l    20 g = c.l.__len__    21 print y             # [2, 4, 6, 8, 10]    22 print g             # __builtins__.list.list.__len__    23 print g()           # 5    24     25 yy = C.l    26 gg = C.l.__len__    27 print yy            # [2, 4, 6, 8, 10]    28 print gg            # __builtins__.list.list.__len__    29 print gg()          # 5    30     31 z = c.s    32 h = c.s.__len__    33 print z             # test    34 print h             # __builtins__.str.basestring.__len__    35 print h()           # 4    36     37 zz = C.s    38 hh = C.s.__len__    39 print zz            # test    40 print hh            # __builtins__.str.basestring.__len__    41 print hh()          # 4    42     43 a = c.y    44 b = c.z    45 i = c.z.__len__    46 print a             # 3    47 print b             # zebra libre    48 print i             # __builtins__.str.basestring.__len__    49 print i()           # 11    50     51 j = C.__len__    52 k = get_using(j, c)    53 try:    54     print j()    55 except UnboundMethodInvocation:    56     print "j(): invocation of method with class context"    57 print k()           # 11