예제 #1
0
    def test_factorial(self):
        code = tlc.compile(FACTORIAL_SOURCE)
        bytecode = ','.join([str(ord(c)) for c in code])

        n = 5
        expected = 120

        res = self.timeshift_from_portal(tlc_interp_without_call,
                                         tlc_interp_eval_without_call,
                                         [bytecode, 0, n],
                                         policy=P_OOPSPEC)#, backendoptimize=True)
        assert res == expected
        self.check_insns(malloc=1)
예제 #2
0
    def test_factorial(self):
        code = tlc.compile(FACTORIAL_SOURCE)
        bytecode = ','.join([str(ord(c)) for c in code])

        n = 5
        expected = 120

        res = self.timeshift_from_portal(
            tlc_interp_without_call,
            tlc_interp_eval_without_call, [bytecode, 0, n],
            policy=P_OOPSPEC)  #, backendoptimize=True)
        assert res == expected
        self.check_insns(malloc=1)
예제 #3
0
 def test_nth_item(self):
     # get the nth item of a chained list
     code = tlc.compile("""
         NIL
         PUSH 40
         CONS
         PUSH 20
         CONS
         PUSH 10
         CONS
         PUSHARG
         DIV
     """)
     bytecode = ','.join([str(ord(c)) for c in code])
     res = self.timeshift_from_portal(tlc_interp_without_call,
                                      tlc_interp_eval_without_call,
                                      [bytecode, 0, 1],
                                      policy=P_OOPSPEC)#, backendoptimize=True)
     assert res == 20
예제 #4
0
 def test_nth_item(self):
     # get the nth item of a chained list
     code = tlc.compile("""
         NIL
         PUSH 40
         CONS
         PUSH 20
         CONS
         PUSH 10
         CONS
         PUSHARG
         DIV
     """)
     bytecode = ','.join([str(ord(c)) for c in code])
     res = self.timeshift_from_portal(
         tlc_interp_without_call,
         tlc_interp_eval_without_call, [bytecode, 0, 1],
         policy=P_OOPSPEC)  #, backendoptimize=True)
     assert res == 20
예제 #5
0
파일: test_tlc.py 프로젝트: alkorzt/pypy
 def exec_code(self, src, inputarg):
     pool = tlc.ConstantPool()
     bytecode = tlc.compile(src, pool)
     interp = self._get_interp(bytecode, pool)
     return self.meta_interp(interp, [0, inputarg], view=False)
예제 #6
0
파일: test_tlc.py 프로젝트: njues/Sypy
 def exec_code(self, src, inputarg):
     pool = tlc.ConstantPool()
     bytecode = tlc.compile(src, pool)
     interp = self._get_interp(bytecode, pool)
     return self.meta_interp(interp, [0, inputarg])