|
Groovy example source code file (InstructionSequenceHelperClassTest.groovy)
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: |
Other websites by Alvin Alexander:
Life/living in Alaska (OneMansAlaska.com)
How I Sold My Business (HowISoldMyBusiness.com)
Copyright 1998-2011 Alvin Alexander, devdaily.com
All Rights Reserved.