Class AbstractAssemblyTest

    • Constructor Detail

      • AbstractAssemblyTest

        public AbstractAssemblyTest()
    • Method Detail

      • getLanguageID

        protected abstract LanguageID getLanguageID()
        Get the ID of the language under test The test case will automatically attempt to obtain a suitable assembler before the first test is run.
        Returns:
        the ID of the language
      • setUp

        public void setUp()
                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • tearDown

        public void tearDown()
      • dbgPrintTrees

        protected static void dbgPrintTrees​(java.util.Collection<AssemblyParseResult> trees)
        Print a collection of parse trees to the debug printer
        Parameters:
        trees - the trees
      • formatWithCons

        protected java.lang.String formatWithCons​(PseudoInstruction ins)
        Conveniently format the instruction mnemonic and constructor tree
        Parameters:
        ins - the instruction unit
        Returns:
        a nice display
      • checkOneCompat

        protected void checkOneCompat​(java.lang.String instr,
                                      AssemblyResolutionResults rr)
        Confirm that one of the assembly results matches the pattern described by instr
        Parameters:
        instr - a hex-ish representation of the instruction pattern
        rr - the collection of assembly resolutions
        See Also:
        AssemblyPatternBlock.fromString(String)
      • checkAllExact

        protected void checkAllExact​(AssemblyResolutionResults rr,
                                     java.util.Collection<java.lang.String> disassembly,
                                     long addr,
                                     java.lang.String ctxstr)
        Confirm that every non-erroneous resolution disassembles to the given text
        Parameters:
        rr - the collection of assembly resolutions
        disassembly - the expected disassembly text
        addr - the address of the instruction(s)
        ctxstr - a string describing the input context pattern
        See Also:
        AssemblyPatternBlock.fromString(String)
      • checkAllSyntaxErrs

        protected void checkAllSyntaxErrs​(java.util.Collection<AssemblyParseResult> parse)
        Confirm that every parse result describes an error, i.e., the text failed to parse.
        Parameters:
        parse - the collection of parse results
      • checkAllSemanticErrs

        protected void checkAllSemanticErrs​(AssemblyResolutionResults res)
        Confirm that every resolution result describes an error, i.e., the text failed to assemble
        Parameters:
        res - the collection of assembly resolutions
      • runTest

        protected void runTest​(java.lang.String assembly,
                               java.lang.String instr,
                               java.util.Collection<java.lang.String> disassembly,
                               long addr,
                               java.lang.String ctxstr,
                               boolean checkOneCompat,
                               boolean checkAllExact,
                               boolean checkAllSyntaxErrs,
                               boolean checkAllSemanticErrs)
        Run a test with the given checks
        Parameters:
        assembly - the text to assembly
        instr - an instruction pattern that must appear in the results
        disassembly - a set of acceptable disassembly texts
        addr - the address for assembly and disassembly
        ctxstr - the context for assembly and disassembly
        checkOneCompat - if instr != null check that one result matches it
        checkAllExact - if disassembly != null check that all are acceptable
        checkAllSyntaxErrs - confirm that assembly does not parse
        checkAllSemanticErrs - confirm that assembly does not assemble
        See Also:
        AssemblyPatternBlock.fromString(String)
      • assertOneCompatRestExact

        protected void assertOneCompatRestExact​(java.lang.String assembly,
                                                java.lang.String instr)
        Run a test where one result must match a given instruction pattern, and all others must disassemble exactly to the input
        Parameters:
        assembly - the input assembly
        instr - the instruction pattern
        See Also:
        AssemblyPatternBlock.fromString(String)
      • assertOneCompatRestExact

        protected void assertOneCompatRestExact​(java.lang.String assembly,
                                                java.lang.String instr,
                                                java.lang.String... disassemblies)
        Run a test where one result must match a given instruction pattern, and all others must disassemble to an acceptable result
        Parameters:
        assembly - the input assembly
        instr - the instruction pattern
        disassemblies - the set of acceptable disassemblies
        See Also:
        AssemblyPatternBlock.fromString(String)
      • assertOneCompatRestExact

        protected void assertOneCompatRestExact​(java.lang.String assembly,
                                                java.lang.String instr,
                                                long addr,
                                                java.lang.String... disassemblies)
        Like assertOneCompatRestExact(String, String, long), except an alternative disassembly is given
        Parameters:
        assembly - the input assembly
        instr - the instruction pattern
        addr - the address for assembly and disassembly
        disassemblies - the set of acceptable disassemblies
        See Also:
        AssemblyPatternBlock.fromString(String)
      • assertOneCompatRestExact

        protected void assertOneCompatRestExact​(java.lang.String assembly,
                                                java.lang.String instr,
                                                java.lang.String ctxstr,
                                                long addr,
                                                java.lang.String... disassemblies)
        Like {@link #assertOneCompatRestExact(String, String, String, long), except a context is given
        Parameters:
        assembly - the input assembly
        instr - the instruction pattern
        addr - the address for assembly and disassembly
        ctxstr - the context pattern for assembly and disassembly
        disassemblies - the set of acceptable disassemblies
        See Also:
        AssemblyPatternBlock.fromString(String)
      • assertAllSyntaxErrors

        protected void assertAllSyntaxErrors​(java.lang.String assembly)
        Run a test checking that the given assembly does not parse
        Parameters:
        assembly - the input assembly
      • assertAllSemanticErrors

        protected void assertAllSemanticErrors​(java.lang.String assembly)
        Run a test checking that the given assembly parses, but does not assemble
        Parameters:
        assembly - the input assembly
      • assertAllSemanticErrors

        protected void assertAllSemanticErrors​(java.lang.String assembly,
                                               java.lang.String ctxstr)
        Like {@link # assertAllSemanticErrors(String), but a context is given
        Parameters:
        assembly - the input assembly
        ctxstr - the context pattern for assembly
        See Also:
        AssemblyPatternBlock.fromString(String)