|
Groovy example source code file (SourceBaseTestCase.groovy)
The Groovy SourceBaseTestCase.groovy source codepackage org.codehaus.groovy.ast.source import org.codehaus.groovy.control.* import org.codehaus.groovy.control.io.* import org.codehaus.groovy.ast.stmt.* class SourceBaseTestCase extends GroovyTestCase { private classNode public classNode() { if (classNode!=null) return node def cu = new CompilationUnit(null,null,this.class.classLoader) def source = new StringReaderSource(script,cu.configuration) def su = cu.addSource(new SourceUnit("Script_"+this.name, source, cu.configuration, cu.classLoader, cu.errorCollector)) cu.compile(Phases.CONVERSION) classNode = cu.firstClassNode return classNode } def sourceInfo(expression) { return [ expression.lineNumber, expression.columnNumber, expression.lastLineNumber, expression.lastColumnNumber ] } def statements(String method="run") { def ret = classNode().getMethod(method).code if (ret instanceof BlockStatement) return ret.statements if (ret==null) return null return [ret] } } Other Groovy examples (source code examples)Here is a short list of links related to this Groovy SourceBaseTestCase.groovy source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.