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

Groovy example source code file (SourceBaseTestCase.groovy)

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

Java - Groovy tags/keywords

blockstatement, blockstatement, groovytestcase, script_, script_, sourcebasetestcase, sourcebasetestcase, sourceunit, sourceunit

The Groovy SourceBaseTestCase.groovy source code

package org.codehaus.groovy.ast.source

import org.codehaus.groovy.control.*
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_", source, cu.configuration, cu.classLoader, cu.errorCollector))
      classNode = cu.firstClassNode
      return classNode
    def sourceInfo(expression) {
      return [  expression.lineNumber,
    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


new blog posts


Copyright 1998-2021 Alvin Alexander,
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.