| 117 | ################################################################## |
| 118 | ### Some tests |
| 119 | def test(): |
| 120 | # ----------------------------------------------------- |
| 121 | # Code to execute as function 'f' (as a string): |
| 122 | s = """ |
| 123 | if a == "BE RECURSIVE": |
| 124 | print "In the recursion 1" |
| 125 | return __TheFunction__("THE END", 54) |
| 126 | elif a == "THE END": |
| 127 | print "In the recursion 2" |
| 128 | return 54 |
| 129 | |
| 130 | print a |
| 131 | print b |
| 132 | x = True |
| 133 | |
| 134 | def sayhello(s): |
| 135 | print "I say hello that way: %s" % s |
| 136 | |
| 137 | class SayHello(object): |
| 138 | def __init__(self, s): |
| 139 | self.__s = s |
| 140 | print "ctor says %s" % self.__s |
| 141 | |
| 142 | def s(self): |
| 143 | return self.__s |
| 144 | try: |
| 145 | 1/0 |
| 146 | except ZeroDivisionError, ex: |
| 147 | print "GOT EX", ex |
| 148 | |
| 149 | print "ooo in here says", ooo.mouf() |
| 150 | |
| 151 | result = a + b +1 |
| 152 | afunction(a+1) |
| 153 | c = re.compile("^a").search("ba", 1) |
| 154 | d = re.compile("a").match("ba", 1) |
| 155 | sayhello("I am so happy today %s,%s" % (c, d)) |
| 156 | o = SayHello("this works") |
| 157 | vvv = range(42) |
| 158 | print vvv |
| 159 | sys.stderr.write("writing to stderr\\n") |
| 160 | |
| 161 | print __TheFunction__ |
| 162 | print "============ BEGIN docstring ===========" |
| 163 | print __TheFunction__.__doc__ |
| 164 | print "============ END docstring ===========" |
| 165 | return a*b + __TheFunction__("BE RECURSIVE", 33) |
| 166 | """ |
| 167 | # End of source code string |
| 168 | # ----------------------------------------------------- |
| 169 | |
| 170 | # Create objects, functions, etc. |
| 171 | class OOO: |
| 172 | def __init__(self, id): |
| 173 | self.__id = id |
| 174 | def mouf(self): |
| 175 | return "OOO: My ID is %s" % self.__id |
| 176 | def F(n): |