Exemple #1
0
def test_relative_mode():
    subject = Interpreter([109, 5, 109, -4, 204, 3, 99])

    subject.run()

    assert subject._rbo == 1
    assert subject.stdout.get() == 204
Exemple #2
0
def test_set():
    subject = Interpreter([3, 0, 99])
    subject.put(5)

    subject.run()

    assert subject[0] == 5
Exemple #3
0
def test_day_9_quine_test(capsys):
    program = [
        109, 1, 204, -1, 1001, 100, 1, 100, 1008, 100, 16, 101, 1006, 101, 0,
        99
    ]
    subject = Interpreter(program)

    subject.run()
    # subject.DEBUG = True
    # with capsys.disabled():
    #     print()
    #     print(f'  MEM| (IC: {subject._ic}, RBO: {subject._rbo})', subject[:])
    #     while not subject.finished:
    #         subject.step()
    #         print(f'  MEM| (IC: {subject._ic}, RBO: {subject._rbo})', subject[:])

    assert list(subject.stream()) == program
Exemple #4
0
def test_day_9_more_tests(program, result):
    subject = Interpreter(program)
    subject.run()
    assert subject.get() == result
Exemple #5
0
def test_day_5_jump_test(program, param, result):
    subject = Interpreter(program)
    subject.put(param)
    subject.run()
    assert subject.get() == result
Exemple #6
0
def test_read_from_somewhere():
    subject = Interpreter([4, 100, 99])

    subject.run()

    assert subject.stdout.get() == 0
Exemple #7
0
def test_add():
    subject = Interpreter([1, 0, 0, 0, 99])

    subject.run()

    assert subject[0] == 2
Exemple #8
0
def test_out():
    subject = Interpreter([4, 0, 99])

    subject.run()

    assert subject.stdout.get() == 4
Exemple #9
0
def test_multiply_param_modes():
    subject = Interpreter([1002, 4, 3, 4, 33])

    subject.run()

    assert subject[:] == (1002, 4, 3, 4, 99)
Exemple #10
0
def test_multiply():
    subject = Interpreter([2, 3, 0, 3, 99])

    subject.run()

    assert subject[3] == 6