def test_new_vs_reference_code_stream_read(read_len, bytecode): reference = SlowCodeStream(bytecode) latest = CodeStream(bytecode) readout_expected = reference.read(read_len) readout_actual = latest.read(read_len) assert readout_expected == readout_actual if read_len <= len(bytecode): assert latest.program_counter == reference.program_counter assert latest.read(1) == reference.read(1)
def test_new_vs_reference_code_stream_read_during_iter(read_idx, read_len, bytecode): reference = SlowCodeStream(bytecode) latest = CodeStream(bytecode) for index, (actual, expected) in enumerate(zip(latest, reference)): assert actual == expected if index == read_idx: readout_actual = latest.read(read_len) readout_expected = reference.read(read_len) assert readout_expected == readout_actual if reference.program_counter >= len(reference): assert latest.program_counter >= len(reference) else: assert latest.program_counter == reference.program_counter