示例#1
0
 def test_obj_equality(self):
     from rpython.jit.tl.tlc import interp_eval, nil
     pool = ConstantPool()
     bytecode = compile("""
         NEW foo,bar
         NEW foo,bar
         EQ
     """, pool)
     res = interp_eval(bytecode, 0, [nil], pool)
     assert res.int_o() == 0
示例#2
0
 def test_new_obj(self):
     from rpython.jit.tl.tlc import interp_eval, InstanceObj, nil
     pool = ConstantPool()
     bytecode = compile("""
         NEW foo,bar
     """, pool)
     obj = interp_eval(bytecode, 0, [nil], pool)
     assert isinstance(obj, InstanceObj)
     assert len(obj.values) == 2
     assert sorted(obj.cls.attributes.keys()) == ['bar', 'foo']
示例#3
0
 def test_call_without_return_value(self):
     from rpython.jit.tl.tlc import interp_eval, nil
     pool = ConstantPool()
     bytecode = compile("""
         CALL foo
         PUSH 42
         RETURN
     foo:
         RETURN
     """, pool)
     res = interp_eval(bytecode, 0, [nil], pool)
     assert res.int_o() == 42
示例#4
0
 def test_getattr(self):
     from rpython.jit.tl.tlc import interp_eval, nil
     pool = ConstantPool()
     bytecode = compile("""
         NEW foo,bar
         PICK 0
         PUSH 42
         SETATTR bar
         GETATTR bar
     """, pool)
     res = interp_eval(bytecode, 0, [nil], pool)
     assert res.int_o() == 42
示例#5
0
 def test_setattr(self):
     from rpython.jit.tl.tlc import interp_eval, nil
     pool = ConstantPool()
     bytecode = compile("""
         NEW foo,bar
         PICK 0
         PUSH 42
         SETATTR foo
     """, pool)
     obj = interp_eval(bytecode, 0, [nil], pool)
     assert obj.values[0].int_o() == 42
     assert obj.values[1] is nil
示例#6
0
 def test_obj_truth(self):
     from rpython.jit.tl.tlc import interp_eval, nil
     pool = ConstantPool()
     bytecode = compile("""
         NEW foo,bar
         BR_COND true
         PUSH 12
         PUSH 1
         BR_COND exit
     true:
         PUSH 42
     exit:
         RETURN
     """, pool)
     res = interp_eval(bytecode, 0, [nil], pool)
     assert res.int_o() == 42
示例#7
0
 def test_method(self):
     from rpython.jit.tl.tlc import interp_eval, nil
     pool = ConstantPool()
     bytecode = compile("""
         NEW foo,meth=meth
         PICK 0
         PUSH 42
         SETATTR foo
         SEND meth/0
         RETURN
     meth:
         PUSHARG
         GETATTR foo
         RETURN
     """, pool)
     res = interp_eval(bytecode, 0, [nil], pool)
     assert res.int_o() == 42
示例#8
0
 def interp(i, inputarg):
     args = [tlc.IntObj(inputarg)]
     obj = tlc.interp_eval(codes[i], 0, args, pools[i])
     return obj.int_o()
示例#9
0
 def interp(i, inputarg):
     args = [tlc.IntObj(inputarg)]
     obj = tlc.interp_eval(codes[i], 0, args, pools[i])
     return obj.int_o()
示例#10
0
 def fn(n):
     obj = IntObj(n)
     res = interp_eval(bytecode, 0, [obj], pool)
     return res.int_o()