home | career | drupal | java | mac | mysql | perl | scala | uml | unix

Groovy example source code file (InstructionSequenceHelperClassTest.groovy)

This example Groovy source code file (InstructionSequenceHelperClassTest.groovy) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

a, a, b, c, c, d, d, e, e, f, groovytestcase, iadd, iload, instructionsequence

The Groovy InstructionSequenceHelperClassTest.groovy source code

package org.codehaus.groovy.classgen.asm

/**
 * Test the utility class InstructionSequence for testing bytecode instructions generated by Groovy
 *
 * @author Guillaume Laforge
 */
class InstructionSequenceHelperClassTest extends GroovyTestCase {

    static final seq = new InstructionSequence(instructions: [
                "A 1",
                "B 2",
                "C",
                "D 3",
                "E 4",
                "F"
        ])

    void testSequence() {
        assert seq.hasSequence([
                "A 1",
                "B 2",
                "C",
                "D 3",
                "E 4",
                "F"
        ])

        assert seq.hasSequence([
                "A",
                "B",
                "C",
                "D",
                "E",
                "F"
        ])

        assert seq.hasSequence([
                "A 1",
                "C",
                "E 4",
        ])

        assert seq.hasSequence([
                "A",
                "E 4",
        ])
    }

    void testStrictSequence() {
        assert seq.hasStrictSequence([
                "A 1",
                "B 2",
                "C",
                "D 3",
                "E 4",
                "F"
        ])

        assert seq.hasStrictSequence([
                "B 2",
                "C",
                "D 3",
        ])

        assert seq.hasStrictSequence([
                "A",
                "B",
                "C",
                "D",
                "E",
                "F"
        ])

        assert seq.hasStrictSequence([
                "B",
                "C",
                "D",
        ])
    }

    void testStrictSequenceWithBytecodeExample() {
        def instrs = new InstructionSequence(instructions: [
                "ILOAD 9",
                "ILOAD 11",
                "IADD"
        ])

        assert instrs.hasStrictSequence([
                "ILOAD",
                "ILOAD",
                "IADD"
        ])
    }
}

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy InstructionSequenceHelperClassTest.groovy source code file:

new blog posts

 

Copyright 1998-2014 Alvin Alexander, alvinalexander.com
All Rights Reserved.