Package org.encog.script.javascript

Source Code of org.encog.script.javascript.TestJavaScript

package org.encog.script.javascript;


import org.encog.script.EncogScript;

import junit.framework.Assert;
import junit.framework.TestCase;

public class TestJavaScript extends TestCase {

  public void testHelloWorld()
  {
    StringConsole console = new StringConsole();
    EncogJavascriptEngine.init();
    EncogScript script = new EncogScript();
    script.setSource("console.print(\'Hello World\')\n");
    script.run(console);
    Assert.assertEquals(console.toString(),"Hello World");   
  }
 
  public void testLoop()
  {
    StringConsole console = new StringConsole();
    EncogJavascriptEngine.init();
    EncogScript script = new EncogScript();
    script.setSource("for(i=0;i<10;i++){console.print(i);}\n");
    script.run(console);
    Assert.assertEquals(console.toString(),"0.01.02.03.04.05.06.07.08.09.0");   
  }
}
TOP

Related Classes of org.encog.script.javascript.TestJavaScript

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.