alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Groovy example source code file (AstBuilderFromCodePackageImportTest.groovy)

This example Groovy source code file (AstBuilderFromCodePackageImportTest.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

astbuilderfromcodepackageimporttest, astbuilderfromcodepackageimporttest, groovytestcase, hello, hello, withastbuilder, withastbuilder, world, world

The Groovy AstBuilderFromCodePackageImportTest.groovy source code

package org.codehaus.groovy.ast.builder.testpackage

import org.codehaus.groovy.ast.builder.*
import org.codehaus.groovy.runtime.MethodClosure

/**
 * Test package imports in AstBuilder.
 * 
 * It is important that this class contains an import of builder.* and not 
 * the AstBuilder class individually. 
 *
 * @author Hamlet D'Arcy
 */
@WithAstBuilder
public class AstBuilderFromCodePackageImportTest extends GroovyTestCase {

    public void testPackageImport() {

        def expected = new AstBuilder().buildFromString(""" println "Hello World" """)

        def result = new AstBuilder().buildFromCode {
            println "Hello World"
        }
        AstAssert.assertSyntaxTree(expected, result)
    }

}

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy AstBuilderFromCodePackageImportTest.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, 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.