view src/org/RhinoTests/CompiledScriptTest.java @ 352:9b40969f01e3 draft

Added new tests into CompiledScriptTest.
author Pavel Tisnovsky <ptisnovs@redhat.com>
date Thu, 10 Apr 2014 11:05:49 +0200
parents 5674e01de2f4
children 5f9eba77856c
line wrap: on
line source

/*
  Rhino test framework

   Copyright (C) 2011  Red Hat

This file is part of IcedTea.

IcedTea is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

IcedTea is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with IcedTea; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.

Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.

As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module.  An independent module is a module which is not derived from
or based on this library.  If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so.  If you do not wish to do so, delete this
exception statement from your version.
*/

package org.RhinoTests;

import javax.script.Compilable;
import javax.script.CompiledScript;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

/**
 * This test case check the behaviour of CompiledScript abstract class and it's
 * descendents.
 * 
 * @author Pavel Tisnovsky
 */
public class CompiledScriptTest extends BaseRhinoTest {

	/**
	 * Instance of ScriptEngineManager which is used by all tests in this test
	 * case.
	 */
    ScriptEngineManager engineManager;

	/**
	 * Instance of ScriptEngine which is used by all tests in this test case.
	 */
    ScriptEngine scriptEngine;

	@Override
	protected void setUp(String[] args) {
        // setup attribute used by tests
        this.engineManager = new ScriptEngineManager();
        this.scriptEngine = this.engineManager.getEngineByName("JavaScript");
	}

	@Override
	protected void tearDown() {
        // this block could be empty
        return;
	}

	/**
	 * Helper method which tries to retrieve an instance of class which
	 * implements CompiledScript interface for a given script.
	 * 
	 * @param scriptText
	 *            script source code
	 * @return instance of CompiledScript class
	 * @throws AssertionError
	 *             when CompilingEngine cannot be retrieved
	 * @throws ScriptException
	 *             thrown when script cannot be compiled
	 */
	private CompiledScript getCompiledScript(String scriptText) throws AssertionError, ScriptException {
		// check if retyping could be done
		assertTrue(this.scriptEngine instanceof Compilable, "ScriptEngine does not implement Compilable");
		// scriptEngine should be also retyped to Compilable, at least in case of JavaScript.
		Compilable compilingEngine = (Compilable) this.scriptEngine;
		// should not happen, but...
		assertNotNull(compilingEngine, "cannot get compiling engine");
		// try to compile given script
		return compileScript(scriptText, compilingEngine);
	}

	/**
	 * Helper method which tries to compile given JavaScript.
	 *
	 * @param scriptText script source code
	 * @param compilingEngine instance of class which implements Compilable interface
	 * @return compiled script
	 * @throws ScriptException
	 * @throws AssertionError
	 */
	private CompiledScript compileScript(String scriptText, Compilable compilingEngine) throws ScriptException, AssertionError {
		CompiledScript script = compilingEngine.compile(scriptText);
		assertNotNull(script, "cannot compile script");
		return script;
	}

    /**
     * Test if it is possible to compile script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testCompileEmptyScript1StoredInString() throws ScriptException {
    	Compilable compilingEngine = (Compilable)this.scriptEngine;
    	assertNotNull(compilingEngine, "cannot get compiling engine");
		if (compilingEngine != null) {
			CompiledScript script = compilingEngine.compile(JavaScriptSnippets.EMPTY_SCRIPT_1);
			assertNotNull(script, "cannot compile script");
		}
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testCompileAndRunSimpleScriptStoredInString() throws ScriptException {
    	CompiledScript script = getCompiledScript(JavaScriptSnippets.EMPTY_SCRIPT_1);
    	Object result = script.eval();
    	assertNull(result, "result should be null");
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalNumericExpression0() throws ScriptException {
    	final String expression = JavaScriptSnippets.NUMERIC_EXPRESSION_0;
    	CompiledScript script = getCompiledScript(expression);
    	Object result = script.eval();
    	assertNotNull(result, "result should not be null");
    	assertTrue(result instanceof Number, "result is not an instance of Number");
		if (getJavaVersion() >= 7) {
			assertTrue(result instanceof Double, "result is not an instance of Double");
			double doubleResult = ((Double) result).doubleValue();
			assertEquals(doubleResult, 42, "wrong result " + doubleResult + " for the expression: '" + expression + "'");
		}
		else {
			assertTrue(result instanceof Integer, "result is not an instance of Integer");
			int integerResult = ((Integer) result).intValue();
			assertEquals(integerResult, 42, "wrong result " + integerResult + " for the expression: '" + expression + "'");
		}
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalNumericExpression1() throws ScriptException {
    	final String expression = JavaScriptSnippets.NUMERIC_EXPRESSION_1;
    	CompiledScript script = getCompiledScript(expression);
    	Object result = script.eval();
    	assertNotNull(result, "result should not be null");
    	assertTrue(result instanceof Number, "result is not an instance of Number");
		if (getJavaVersion() >= 7) {
			assertTrue(result instanceof Double, "result is not an instance of Double");
			double doubleResult = ((Double) result).doubleValue();
			assertEquals(doubleResult, 3, "wrong result " + doubleResult + " for the expression: '" + expression + "'");
		}
		else {
			assertTrue(result instanceof Integer, "result is not an instance of Integer");
			int integerResult = ((Integer) result).intValue();
			assertEquals(integerResult, 3, "wrong result " + integerResult + " for the expression: '" + expression + "'");
		}
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalNumericExpression2() throws ScriptException {
    	final String expression = JavaScriptSnippets.NUMERIC_EXPRESSION_2;
    	CompiledScript script = getCompiledScript(expression);
    	Object result = script.eval();
    	assertNotNull(result, "result should not be null");
    	assertTrue(result instanceof Number, "result is not an instance of Number");
		if (getJavaVersion() >= 7) {
			assertTrue(result instanceof Double, "result is not an instance of Double");
			double doubleResult = ((Double) result).doubleValue();
			assertEquals(doubleResult, 6, "wrong result " + doubleResult + " for the expression: '" + expression + "'");
		}
		else {
			assertTrue(result instanceof Integer, "result is not an instance of Integer");
			int integerResult = ((Integer) result).intValue();
			assertEquals(integerResult, 6, "wrong result " + integerResult + " for the expression: '" + expression + "'");
		}
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalNumericExpression3() throws ScriptException {
    	final String expression = JavaScriptSnippets.NUMERIC_EXPRESSION_3;
    	CompiledScript script = getCompiledScript(expression);
    	Object result = script.eval();
    	assertNotNull(result, "result should not be null");
    	assertTrue(result instanceof Number, "result is not an instance of Number");
		if (getJavaVersion() >= 7) {
			assertTrue(result instanceof Double, "result is not an instance of Double");
			double doubleResult = ((Double) result).doubleValue();
			assertEquals(doubleResult, 7, "wrong result " + doubleResult + " for the expression: '" + expression + "'");
		}
		else {
			assertTrue(result instanceof Integer, "result is not an instance of Integer");
			int integerResult = ((Integer) result).intValue();
			assertEquals(integerResult, 7, "wrong result " + integerResult + " for the expression: '" + expression + "'");
		}
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalNumericExpression4() throws ScriptException {
    	final String expression = JavaScriptSnippets.NUMERIC_EXPRESSION_4;
    	CompiledScript script = getCompiledScript(expression);
    	Object result = script.eval();
    	assertNotNull(result, "result should not be null");
    	assertTrue(result instanceof Number, "result is not an instance of Number");
		if (getJavaVersion() >= 7) {
			assertTrue(result instanceof Double, "result is not an instance of Double");
			double doubleResult = ((Double) result).doubleValue();
			assertEquals(doubleResult, 5, "wrong result " + doubleResult + " for the expression: '" + expression + "'");
		}
		else {
			assertTrue(result instanceof Integer, "result is not an instance of Integer");
			int integerResult = ((Integer) result).intValue();
			assertEquals(integerResult, 5, "wrong result " + integerResult + " for the expression: '" + expression + "'");
		}
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalNumericExpression5() throws ScriptException {
    	final String expression = JavaScriptSnippets.NUMERIC_EXPRESSION_5;
    	CompiledScript script = getCompiledScript(expression);
    	Object result = script.eval();
    	assertNotNull(result, "result should not be null");
    	assertTrue(result instanceof Number, "result is not an instance of Number");
		if (getJavaVersion() >= 7) {
			assertTrue(result instanceof Double, "result is not an instance of Double");
			double doubleResult = ((Double) result).doubleValue();
			assertEquals(doubleResult, 7, "wrong result " + doubleResult + " for the expression: '" + expression + "'");
		}
		else {
			assertTrue(result instanceof Integer, "result is not an instance of Integer");
			int integerResult = ((Integer) result).intValue();
			assertEquals(integerResult, 7, "wrong result " + integerResult + " for the expression: '" + expression + "'");
		}
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalNumericExpression6() throws ScriptException {
    	final String expression = JavaScriptSnippets.NUMERIC_EXPRESSION_6;
    	CompiledScript script = getCompiledScript(expression);
    	Object result = script.eval();
    	assertNotNull(result, "result should not be null");
    	assertTrue(result instanceof Number, "result is not an instance of Number");
		if (getJavaVersion() >= 7) {
			assertTrue(result instanceof Double, "result is not an instance of Double");
			double doubleResult = ((Double) result).doubleValue();
			assertEquals(doubleResult, 9, "wrong result " + doubleResult + " for the expression: '" + expression + "'");
		}
		else {
			assertTrue(result instanceof Integer, "result is not an instance of Integer");
			int integerResult = ((Integer) result).intValue();
			assertEquals(integerResult, 9, "wrong result " + integerResult + " for the expression: '" + expression + "'");
		}
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalNumericExpression7() throws ScriptException {
    	final String expression = JavaScriptSnippets.NUMERIC_EXPRESSION_7;
    	CompiledScript script = getCompiledScript(expression);
    	Object result = script.eval();
    	assertNotNull(result, "result should not be null");
    	assertTrue(result instanceof Number, "result is not an instance of Number");
		if (getJavaVersion() >= 7) {
			assertTrue(result instanceof Double, "result is not an instance of Double");
			double doubleResult = ((Double) result).doubleValue();
			assertEquals(doubleResult, 42, "wrong result " + doubleResult + " for the expression: '" + expression + "'");
		}
		else {
			assertTrue(result instanceof Integer, "result is not an instance of Integer");
			int integerResult = ((Integer) result).intValue();
			assertEquals(integerResult, 42, "wrong result " + integerResult + " for the expression: '" + expression + "'");
		}
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalNumericExpression8() throws ScriptException {
    	final String expression = JavaScriptSnippets.NUMERIC_EXPRESSION_8;
    	CompiledScript script = getCompiledScript(expression);
    	Object result = script.eval();
    	assertNotNull(result, "result should not be null");
    	assertTrue(result instanceof Number, "result is not an instance of Number");
		if (getJavaVersion() >= 7) {
			assertTrue(result instanceof Double, "result is not an instance of Double");
			double doubleResult = ((Double) result).doubleValue();
			assertEquals(doubleResult, 42, "wrong result " + doubleResult + " for the expression: '" + expression + "'");
		}
		else {
			assertTrue(result instanceof Integer, "result is not an instance of Integer");
			int integerResult = ((Integer) result).intValue();
			assertEquals(integerResult, 42, "wrong result " + integerResult + " for the expression: '" + expression + "'");
		}
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalNumericExpression9() throws ScriptException {
    	final String expression = JavaScriptSnippets.NUMERIC_EXPRESSION_9;
    	CompiledScript script = getCompiledScript(expression);
    	Object result = script.eval();
    	assertNotNull(result, "result should not be null");
    	assertTrue(result instanceof Number, "result is not an instance of Number");
		if (getJavaVersion() >= 7) {
			assertTrue(result instanceof Double, "result is not an instance of Double");
			double doubleResult = ((Double) result).doubleValue();
			assertEquals(doubleResult, 3, "wrong result " + doubleResult + " for the expression: '" + expression + "'");
		}
		else {
			assertTrue(result instanceof Integer, "result is not an instance of Integer");
			int integerResult = ((Integer) result).intValue();
			assertEquals(integerResult, 3, "wrong result " + integerResult + " for the expression: '" + expression + "'");
		}
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalNumericExpression10() throws ScriptException {
    	final String expression = JavaScriptSnippets.NUMERIC_EXPRESSION_10;
    	CompiledScript script = getCompiledScript(expression);
    	Object result = script.eval();
    	assertNotNull(result, "result should not be null");
    	assertTrue(result instanceof Number, "result is not an instance of Number");
		if (getJavaVersion() >= 7) {
			assertTrue(result instanceof Double, "result is not an instance of Double");
			double doubleResult = ((Double) result).doubleValue();
			assertEquals(doubleResult, 6, "wrong result " + doubleResult + " for the expression: '" + expression + "'");
		}
		else {
			assertTrue(result instanceof Integer, "result is not an instance of Integer");
			int integerResult = ((Integer) result).intValue();
			assertEquals(integerResult, 6, "wrong result " + integerResult + " for the expression: '" + expression + "'");
		}
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalDoubleExpression1() throws ScriptException {
    	final String expression = JavaScriptSnippets.DOUBLE_NUMERIC_EXPRESSION_1;
    	CompiledScript script = getCompiledScript(expression);
    	Object result = script.eval();
    	assertTrue(result instanceof Number, "result is not an instance of Number");
    	assertTrue(result instanceof Double, "result is not an instance of Integer");
		double doubleResult = ((Double) result).doubleValue();
    	assertEquals(doubleResult, 0.5f, "wrong result " + doubleResult + " for the expression: '" + expression + "'");
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalDoubleExpression2() throws ScriptException {
    	final String expression = JavaScriptSnippets.DOUBLE_NUMERIC_EXPRESSION_2;
    	CompiledScript script = getCompiledScript(expression);
    	Object result = script.eval();
    	assertTrue(result instanceof Number, "result is not an instance of Number");
    	assertTrue(result instanceof Double, "result is not an instance of Integer");
		double doubleResult = ((Double) result).doubleValue();
    	assertEquals(doubleResult, 0.5f, "wrong result " + doubleResult + " for the expression: '" + expression + "'");
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalDoubleExpression3() throws ScriptException {
    	final String expression = JavaScriptSnippets.DOUBLE_NUMERIC_EXPRESSION_3;
    	CompiledScript script = getCompiledScript(expression);
    	Object result = script.eval();
    	assertTrue(result instanceof Number, "result is not an instance of Number");
    	assertTrue(result instanceof Double, "result is not an instance of Integer");
		double doubleResult = ((Double) result).doubleValue();
    	assertEquals(doubleResult, 0.5f, "wrong result " + doubleResult + " for the expression: '" + expression + "'");
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalBooleanExpression1() throws ScriptException {
    	final String expression = JavaScriptSnippets.BOOLEAN_EXPRESSION_1;
    	CompiledScript script = getCompiledScript(expression);
    	Object result = script.eval();
    	assertTrue(result instanceof Boolean, "result is not an instance of Boolean");
		boolean booleanResult = ((Boolean) result).booleanValue();
    	assertEquals(booleanResult, true, "wrong result " + booleanResult + " for the expression: '" + expression + "'");
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalBooleanExpression2() throws ScriptException {
    	final String expression = JavaScriptSnippets.BOOLEAN_EXPRESSION_2;
    	CompiledScript script = getCompiledScript(expression);
    	Object result = script.eval();
    	assertTrue(result instanceof Boolean, "result is not an instance of Boolean");
		boolean booleanResult = ((Boolean) result).booleanValue();
    	assertEquals(booleanResult, false, "wrong result " + booleanResult + " for the expression: '" + expression + "'");
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalBooleanExpression3() throws ScriptException {
    	final String expression = JavaScriptSnippets.BOOLEAN_EXPRESSION_3;
    	CompiledScript script = getCompiledScript(expression);
    	Object result = script.eval();
    	assertTrue(result instanceof Boolean, "result is not an instance of Boolean");
		boolean booleanResult = ((Boolean) result).booleanValue();
    	assertEquals(booleanResult, false, "wrong result " + booleanResult + " for the expression: '" + expression + "'");
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalBooleanExpression4() throws ScriptException {
    	final String expression = JavaScriptSnippets.BOOLEAN_EXPRESSION_4;
    	CompiledScript script = getCompiledScript(expression);
    	Object result = script.eval();
    	assertTrue(result instanceof Boolean, "result is not an instance of Boolean");
		boolean booleanResult = ((Boolean) result).booleanValue();
    	assertEquals(booleanResult, true, "wrong result " + booleanResult + " for the expression: '" + expression + "'");
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalStringExpression1() throws ScriptException {
    	final String expression = JavaScriptSnippets.STRING_EXPRESSION_1;
    	CompiledScript script = getCompiledScript(expression);
    	Object result = script.eval();
    	assertNotNull(result, "result should not be null");
    	assertTrue(result instanceof String, "result is not an instance of String");
    	String stringResult = (String)result;
    	assertEquals(stringResult, "Hello", "wrong result " + stringResult + " for the expression: '" + expression + "'");
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalStringExpression2() throws ScriptException {
    	final String expression = JavaScriptSnippets.STRING_EXPRESSION_2;
    	CompiledScript script = getCompiledScript(expression);
    	Object result = script.eval();
    	assertNotNull(result, "result should not be null");
    	assertTrue(result instanceof String, "result is not an instance of String");
    	String stringResult = (String)result;
    	assertEquals(stringResult, "Hello world", "wrong result " + stringResult + " for the expression: '" + expression + "'");
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalStringExpression3() throws ScriptException {
    	CompiledScript script = getCompiledScript("'Hello world!'.substring(4, 7)");
    	Object result = script.eval();
    	assertNotNull(result, "result should not be null");
    	assertTrue(result instanceof String, "result is not an instance of String");
    	String stringResult = (String)result;
    	assertEquals(stringResult, "o w", "wrong result " + stringResult);
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalPrintCommand1() throws ScriptException {
    	CompiledScript script = getCompiledScript("print('Hello world\\n')");
    	Object result = script.eval();
    	assertNull(result, "result should be null");
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalPrintCommand2() throws ScriptException {
    	CompiledScript script = getCompiledScript("print('\\tHello world\\n')");
    	Object result = script.eval();
    	assertNull(result, "result should be null");
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalPrintCommand3() throws ScriptException {
    	CompiledScript script = getCompiledScript("print('')");
    	Object result = script.eval();
    	assertNull(result, "result should be null");
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalPrintCommand4() throws ScriptException {
    	CompiledScript script = getCompiledScript("print()");
    	Object result = script.eval();
    	assertNull(result, "result should be null");
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalPrintlnCommand1() throws ScriptException {
    	CompiledScript script = getCompiledScript("println('Hello world')");
    	Object result = script.eval();
    	assertNull(result, "result should be null");
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalPrintlnCommand2() throws ScriptException {
    	CompiledScript script = getCompiledScript("println('\\tHello world')");
    	Object result = script.eval();
    	assertNull(result, "result should be null");
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalPrintlnCommand3() throws ScriptException {
    	CompiledScript script = getCompiledScript("println('')");
    	Object result = script.eval();
    	assertNull(result, "result should be null");
    }

    /**
     * Test if it is possible to compile and then run script from a string.
     * 
     * @throws ScriptException
     *             this exception is thrown when this test case failed.
     */
    protected void testEvalPrintlnCommand4() throws ScriptException {
    	CompiledScript script = getCompiledScript("println()");
    	Object result = script.eval();
    	assertNull(result, "result should be null");
    }

	/**
     * Entry point to this test case.
     *
     * @param args parameters passed from command line
     */
    public static void main(String[] args) {
    	new CompiledScriptTest().doTests(args);
    }

}