Add artifacts to Maven central repository.
This commit is contained in:
@@ -11,7 +11,7 @@ public class App
|
||||
{
|
||||
public static void main( String[] args )
|
||||
{
|
||||
String script = "print 'hello, from luaj!'";
|
||||
String script = "print('hello, world', _VERSION)";
|
||||
|
||||
// create an environment to run in
|
||||
Globals globals = JsePlatform.standardGlobals();
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
package acme;
|
||||
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.luaj.vm2.Globals;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
import org.luaj.vm2.lib.jse.JsePlatform;
|
||||
|
||||
import acme.App;
|
||||
|
||||
/**
|
||||
* Skeleton unit test for App, required for maven to be used to build the app.
|
||||
*/
|
||||
@@ -18,7 +28,22 @@ public class AppTest
|
||||
return new TestSuite( AppTest.class );
|
||||
}
|
||||
|
||||
public void testAppCanBeExecuted() {
|
||||
public void testMainProgramExecution() {
|
||||
App.main(new String[0]);
|
||||
}
|
||||
|
||||
public void testScriptEngineEvaluation() throws ScriptException {
|
||||
ScriptEngineManager sem = new ScriptEngineManager();
|
||||
ScriptEngine e = sem.getEngineByExtension(".lua");
|
||||
String result = e.eval("return math.pi").toString().substring(0,8);
|
||||
assertEquals("3.141592", result);
|
||||
}
|
||||
|
||||
public void testDirectEvaluation() {
|
||||
String script = "return math.pow(..., 3)";
|
||||
Globals globals = JsePlatform.standardGlobals();
|
||||
LuaValue chunk = globals.loadString(script, "cube");
|
||||
int result = chunk.call(LuaValue.valueOf(5)).toint();
|
||||
assertEquals(125, result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user