def test_argument_order_ok(self): myjitdriver = JitDriver(greens=['i1', 'r1', 'f1'], reds=[]) class A(object): pass myjitdriver.jit_merge_point(i1=42, r1=A(), f1=3.5)
def test_argument_order_more_precision_later_2(self): myjitdriver = JitDriver(greens=['r1', 'i1', 'r2', 'f1'], reds=[]) class A(object): pass myjitdriver.jit_merge_point(i1=42, r1=None, r2=A(), f1=3.5) e = raises(AssertionError, myjitdriver.jit_merge_point, i1=42, r1=A(), r2=None, f1=3.5) assert "got ['2:REF', '1:INT', '2:REF', '3:FLOAT']" in repr(e.value)
def test_argument_order_more_precision_later_2(self): myjitdriver = JitDriver(greens=['r1', 'i1', 'r2', 'f1'], reds=[]) class A(object): pass myjitdriver.jit_merge_point(i1=42, r1=None, r2=A(), f1=3.5) e = raises(AssertionError, myjitdriver.jit_merge_point, i1=42, r1=A(), r2=None, f1=3.5) assert "got ['2:REF', '1:INT', '2:REF', '3:FLOAT']" in repr(e.value)
def loop(self, program, pc, bracket_map): jitdriver2 = JitDriver(greens=['pc', 'program', 'bracket_map'], reds=['tape']) while pc < len(program): jitdriver2.jit_merge_point(pc=pc, tape=self, program=program, bracket_map=bracket_map) code = program[pc] if code == ">": self.advance() elif code == "<": self.devance() elif code == "+": self.inc() elif code == "-": self.dec() elif code == ".": # print os.write(1, chr(self.get())) elif code == ",": # read from stdin self.set(ord(os.read(0, 1)[0])) elif code == "[" and self.get() == 0: # Skip forward to the matching ] pc = bracket_map[pc] elif code == "]" and self.get() != 0: # Skip back to the matching [ pc = bracket_map[pc] pc += 1 return pc
def loop(self, program, pc, bracket_map): jitdriver2 = JitDriver(greens=['pc', 'program', 'bracket_map'], reds = ['tape']) while pc < len(program): jitdriver2.jit_merge_point(pc=pc, tape=self, program=program, bracket_map=bracket_map) code = program[pc] if code == ">": self.advance() elif code == "<": self.devance() elif code == "+": self.inc() elif code == "-": self.dec() elif code == ".": # print os.write(1, chr(self.get())) elif code == ",": # read from stdin self.set(ord(os.read(0, 1)[0])) elif code == "[" and self.get() == 0: # Skip forward to the matching ] pc = bracket_map[pc] elif code == "]" and self.get() != 0: # Skip back to the matching [ pc = bracket_map[pc] pc += 1 return pc
def test_argument_order_accept_r_uint(self): # this used to fail on 64-bit, because r_uint == r_ulonglong myjitdriver = JitDriver(greens=['i1'], reds=[]) myjitdriver.jit_merge_point(i1=r_uint(42))
def test_argument_order_ok(self): myjitdriver = JitDriver(greens=['i1', 'r1', 'f1'], reds=[]) class A(object): pass myjitdriver.jit_merge_point(i1=42, r1=A(), f1=3.5)
def test_argument_order_accept_r_uint(self): # this used to fail on 64-bit, because r_uint == r_ulonglong myjitdriver = JitDriver(greens=['i1'], reds=[]) myjitdriver.jit_merge_point(i1=r_uint(42))