@Test
public void testProcessDollarLabelOperandWithInterspersedDirectiveAndLabel() {

    List<Instruction> instructions = Arrays.asList(
            new Instruction(InstructionType.INSTRUCTION, "init", Assembler.opcodes.get("j"), null, "ALABEL-$2", null, null, 1),
            new Instruction(InstructionType.INSTRUCTION, null, Assembler.opcodes.get("ldc"), 5L, null, null, null, 2),
            new Instruction(InstructionType.INSTRUCTION, "justalabel", null, null, null, "and comment", null, 3),
            new Instruction(InstructionType.DIRECTIVE, null, null, null, null, null, "#chan chan0", 4),
            new Instruction(InstructionType.INSTRUCTION, "ALABEL", Assembler.opcodes.get("ajw"), 1L, null, null, null, 5)
    );
    List<Instruction> processedInstructions = Assembler.processDollarLabelOperands(instructions);
    checkInstructionEquality(
            new Instruction(InstructionType.INSTRUCTION, "init", Assembler.opcodes.get("j"), null, "ALABEL-__dollar1", null, null, 1),
            processedInstructions.get(0));
    checkInstructionEquality(
            new Instruction(InstructionType.INSTRUCTION, null, Assembler.opcodes.get("ldc"), 5L, null, null, null, 2),
            processedInstructions.get(1));
    checkInstructionEquality(
            new Instruction(InstructionType.INSTRUCTION, "justalabel", null, null, null, "and comment", null, 3),
            processedInstructions.get(2));
    checkInstructionEquality(
            new Instruction(InstructionType.DIRECTIVE, null, null, null, null, null, "#chan chan0", 4),
            processedInstructions.get(3));
    checkInstructionEquality(
            new Instruction(InstructionType.INSTRUCTION, "__dollar1", null, null, null, null, null, 5),
            processedInstructions.get(4));
    checkInstructionEquality(
            new Instruction(InstructionType.INSTRUCTION, "ALABEL", Assembler.opcodes.get("ajw"), 1L, null, null, null, 5),
            processedInstructions.get(5));
}