Skip to content

Commit

Permalink
fix test bug for 386_linux
Browse files Browse the repository at this point in the history
  • Loading branch information
matslina committed Feb 15, 2025
1 parent b21d2a2 commit 8d091ac
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test/awip.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def run(self, cell_size=8, eof_behaviour=EOF_NO_CHANGE, steps=None,
if memory_limit is not None and p > memory_limit:
raise AWIPRuntimeError("pointer moved beyond memory area")
if p >= len(mem):
mem.extend([0]*(1+len(mem)/2))
mem.extend([0]*(1+len(mem)//2))

elif op == INPUT:
eof = True
Expand Down
22 changes: 19 additions & 3 deletions test/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,16 @@ def run_ir(self, code, input, expected_output, steps=5000000):
precond = [0] * 23
precond.append(self.BACKEND_INDEX)
precond.extend(ord(c) for c in (''.join(str(op) for op in code)))
precond.extend([0, max_depth/256, max_depth%256])
precond.extend([0, max_depth//256, max_depth%256])

out, _ = self.run_bf(self.code, [], precondition=precond,
pointer=23, steps=steps)

# write backend output to disk
tmpd = tempfile.mkdtemp("awib_%s" % self.__class__.__name__.lower())
prog_path = os.path.join(tmpd, 'prog')
prog = open(prog_path, "w")
prog.write(''.join(chr(i) for i in out))
prog = open(prog_path, "wb")
prog.write(bytes(out))
prog.close()

# run backend output
Expand All @@ -90,6 +91,21 @@ def run_ir(self, code, input, expected_output, steps=5000000):
def test_empty_program(self):
self.run_ir([],[],[])

def test_single_ops(self):
self.run_ir([ir.ADD(1)], [], [])
self.run_ir([ir.SUB(1)], [], [])
self.run_ir([ir.OUTPUT()], [], [0])
self.run_ir([ir.INPUT()], [], [])
self.run_ir([ir.INPUT()], [42], [])
self.run_ir([ir.RIGHT(1)], [], [])
self.run_ir([ir.LEFT(1)], [], [])
self.run_ir([ir.SET(1)], [], [])
self.run_ir([ir.LMUL(1, 1)], [], [])
self.run_ir([ir.RMUL(1, 1)], [], [])

def test_empty_loop(self):
self.run_ir([ir.OPEN(), ir.CLOSE()], [], [])

def test_basic_operations(self):
# ,[->>++++++++<<]>>.[-].[-]+
self.run_ir([ir.INPUT(),
Expand Down

0 comments on commit 8d091ac

Please sign in to comment.