Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Assertion fails when assembling with two delayed definition instruction macros #108

@SamWilsn

Description

@SamWilsn

I think these two test cases (in etk-asm/src/asm.rs) should pass:

    #[test]
    fn assemble_instruction_macro_two_delayed_definitions_mirrored() -> Result<(), Error> {
        let ops = vec![
            AbstractOp::new(GetPc),
            AbstractOp::Macro(InstructionMacroInvocation {
                name: "macro1".into(),
                parameters: vec![],
            }),
            AbstractOp::Macro(InstructionMacroInvocation {
                name: "macro0".into(),
                parameters: vec![],
            }),
            InstructionMacroDefinition {
                name: "macro0".into(),
                parameters: vec![],
                contents: vec![
                    AbstractOp::new(JumpDest),
                ],
            }
            .into(),
            InstructionMacroDefinition {
                name: "macro1".into(),
                parameters: vec![],
                contents: vec![
                    AbstractOp::new(Caller),
                ],
            }
            .into(),
        ];

        let mut asm = Assembler::new();
        let sz = asm.push_all(ops)?;
        assert_eq!(sz, 3);
        let out = asm.take();
        assert_eq!(out, hex!("58335b"));

        Ok(())
    }
    #[test]
    fn assemble_instruction_macro_two_delayed_definitions() -> Result<(), Error> {
        let ops = vec![
            AbstractOp::new(GetPc),
            AbstractOp::Macro(InstructionMacroInvocation {
                name: "macro0".into(),
                parameters: vec![],
            }),
            AbstractOp::Macro(InstructionMacroInvocation {
                name: "macro1".into(),
                parameters: vec![],
            }),
            InstructionMacroDefinition {
                name: "macro0".into(),
                parameters: vec![],
                contents: vec![
                    AbstractOp::new(JumpDest),
                ],
            }
            .into(),
            InstructionMacroDefinition {
                name: "macro1".into(),
                parameters: vec![],
                contents: vec![
                    AbstractOp::new(Caller),
                ],
            }
            .into(),
        ];

        let mut asm = Assembler::new();
        let sz = asm.push_all(ops)?;
        assert_eq!(sz, 3);
        let out = asm.take();
        assert_eq!(out, hex!("585b33"));

        Ok(())
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-assemblerArea: assemblerC-bugCategory: this is a bug, deviation, or other problemE-mediumExperience: of moderate difficulty

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions