def test_cells(self): cell_size = 256 code = ["+" * 67, ".--.", "+" * (cell_size + 1), ".", "-" * (cell_size - 2), "."] code = "".join(code) acc = TextAccumulator() bfeval(code, output_callback = acc) self.assertEqual(acc.get(), "CABD")
def test_helloworld(self): code = ("++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++.." "+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.") acc = TextAccumulator() bfeval(code, output_callback = acc) self.assertEqual(acc.get(), "Hello World!")
# -*- coding: utf-8 -*- import sys from bf import bfeval if __name__ == "__main__": if len(sys.argv) == 2: f = open(sys.argv[1]) code = f.read() f.close() bfeval(code) else: print "USAGE: {} filename".format(sys.argv[0])
def test_memory(self): memory_size = 1024 code = ">" * (memory_size - 1) bfeval(code, memory_size = memory_size) code = ">" * memory_size self.assertRaises(EvalError, bfeval, code, memory_size = memory_size)
def test_emptycode(self): acc = TextAccumulator() bfeval("", output_callback = acc) self.assertEqual(acc.get(), "")