mirror of https://github.com/Nonannet/copapy.git
39 lines
783 B
Python
39 lines
783 B
Python
from coparun_module import coparun
|
|
from copapy import Write, cpvalue
|
|
import copapy
|
|
from copapy import binwrite
|
|
|
|
|
|
def test_compile():
|
|
|
|
c1 = cpvalue(4)
|
|
c2 = cpvalue(2) * 4
|
|
|
|
i1 = c2 * 2
|
|
r1 = i1 + 7 + (c1 + 7 * 9)
|
|
r2 = i1 + 9
|
|
out = [Write(r1), Write(r2), Write(c2)]
|
|
|
|
il, variables = copapy.compile_to_instruction_list(out, copapy.generic_sdb)
|
|
|
|
# run program command
|
|
il.write_com(binwrite.Command.RUN_PROG)
|
|
|
|
for net in (c1, c2, i1, r1, r2):
|
|
copapy.add_read_command(il, variables, net)
|
|
|
|
# run program command
|
|
il.write_com(binwrite.Command.END_COM)
|
|
|
|
#print('* Data to runner:')
|
|
#il.print()
|
|
|
|
print('+ run coparun')
|
|
result = coparun(il.get_data())
|
|
|
|
assert result == 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test_compile()
|