Beispiel #1
0
 def test_mixed_input(self):
     """
     A space-separated string containing numbers and characters is valid.
     """
     input_data = parser.parse_input_data("1 2 a b 3")
     assert input_data == [
         Integer(1), Integer(2), Character('a'), Character('b'), Integer(3)]
Beispiel #2
0
 def test_some_characters(self):
     """
     A space-separated string containing characters is valid input.
     """
     input_data = parser.parse_input_data("a b c")
     assert input_data == [
         Character('a'), Character('b'), Character('c')]
Beispiel #3
0
def entry_point(argv):
    try:
        program_filename = argv[1]
    except IndexError:
        print "I can't run a program if you don't give me one."
        return 1
    try:
        input_filename = argv[2]
    except IndexError:
        print "I can't run a program if you don't give me input."
        return 1
    try:
        memory_filename = argv[3]
    except IndexError:
        memory_filename = None
    program = parse_program(read(program_filename))
    input_data = parse_input_data(read(input_filename))
    assert memory_filename is None, "Not implemented yet."
    mainloop(program, input_data)
    return 0
Beispiel #4
0
 def test_big_numbers(self):
     """
     A space-separated string containing long numbers is valid input.
     """
     input_data = parser.parse_input_data("123 -37")
     assert input_data == [Integer(123), Integer(-37)]
Beispiel #5
0
 def test_some_numbers(self):
     """
     A space-separated string containing numbers is valid input.
     """
     input_data = parser.parse_input_data("1 2 3")
     assert input_data == [Integer(1), Integer(2), Integer(3)]
Beispiel #6
0
 def test_empty_input(self):
     """
     An empty string is empty input.
     """
     input_data = parser.parse_input_data("")
     assert input_data == []