Search in sources :

Example 6 with GroovyShell

use of groovy.lang.GroovyShell in project groovy by apache.

the class MainTest method testMainMethod.

public void testMainMethod() throws Exception {
    GroovyShell shell = new GroovyShell();
    shell.run(new File("src/test/groovy/SampleMain.groovy"), new String[] { "A", "B", "C" });
}
Also used : File(java.io.File) GroovyShell(groovy.lang.GroovyShell)

Example 7 with GroovyShell

use of groovy.lang.GroovyShell in project groovy by apache.

the class UnimplementedSyntaxTest method test_StaticImport1.

// -----------------------
// feature: static imports
// -----------------------
// TODO: move somewhere else
public void test_StaticImport1() throws Exception {
    //GROOVY-3711: The following call now results in a valid script class node, so foo.Bar needs to get resolved.
    GroovyShell groovyShell = new GroovyShell();
    compile("package foo; class Bar{}", groovyShell);
    assertNotNull(compile("import static foo.Bar.mooky", groovyShell));
}
Also used : GroovyShell(groovy.lang.GroovyShell)

Example 8 with GroovyShell

use of groovy.lang.GroovyShell in project groovy by apache.

the class Groovy7826Bug method testComplexTypeArguments.

public void testComplexTypeArguments() throws Exception {
    String script = "def f(org.codehaus.groovy.ast.Groovy7826Bug.C1 c1) { }";
    CompilerConfiguration config = new CompilerConfiguration();
    config.getOptimizationOptions().put("asmResolving", false);
    GroovyShell shell = new GroovyShell(config);
    shell.evaluate(script, "bug7826.groovy");
}
Also used : CompilerConfiguration(org.codehaus.groovy.control.CompilerConfiguration) GroovyShell(groovy.lang.GroovyShell)

Example 9 with GroovyShell

use of groovy.lang.GroovyShell in project groovy by apache.

the class Groovy2553Bug method testMe.

public void testMe() {
    new GroovyShell().evaluate("groovy.bugs.Autobox.Util.printByte(\"1\", Byte.valueOf((byte)1));");
    new GroovyShell().evaluate("groovy.bugs.Autobox.Util.printByte(\"1\", (byte)1);");
}
Also used : GroovyShell(groovy.lang.GroovyShell)

Example 10 with GroovyShell

use of groovy.lang.GroovyShell in project groovy by apache.

the class SeansBug method testMarkupBug.

public void testMarkupBug() throws Exception {
    String[] lines = { "package groovy.xml", "", "b = new MarkupBuilder()", "", "b.root1(a:5, b:7) { ", "    elem1('hello1') ", "    elem2('hello2') ", "    elem3(x:7) ", "}" };
    String code = asCode(lines);
    GroovyShell shell = new GroovyShell();
    shell.evaluate(code);
}
Also used : GroovyShell(groovy.lang.GroovyShell)

Aggregations

GroovyShell (groovy.lang.GroovyShell)86 Binding (groovy.lang.Binding)43 File (java.io.File)15 CompilerConfiguration (org.codehaus.groovy.control.CompilerConfiguration)14 Script (groovy.lang.Script)10 ImportCustomizer (org.codehaus.groovy.control.customizers.ImportCustomizer)10 Closure (groovy.lang.Closure)9 IOException (java.io.IOException)8 List (java.util.List)6 GroovyClassLoader (groovy.lang.GroovyClassLoader)5 GroovyObject (groovy.lang.GroovyObject)4 GroovyRuntimeException (groovy.lang.GroovyRuntimeException)4 AntBuilder (groovy.util.AntBuilder)4 InputStreamReader (java.io.InputStreamReader)4 StringWriter (java.io.StringWriter)4 BuildException (org.apache.tools.ant.BuildException)4 CompilationFailedException (org.codehaus.groovy.control.CompilationFailedException)4 UrlMapping (grails.web.mapping.UrlMapping)3 InputStream (java.io.InputStream)3 PrintWriter (java.io.PrintWriter)3