Example #1
0
 public static void main(String[] args) throws Exception {
   ScriptEngineManager manager = new ScriptEngineManager();
   ScriptEngine jsengine = Helper.getJsEngine(manager);
   if (jsengine == null) {
     System.out.println("Warning: No js engine found; test vacuously passes.");
     return;
   }
   String langVersion = jsengine.getFactory().getLanguageVersion();
   if (!langVersion.equals(JS_LANG_VERSION)) {
     throw new RuntimeException("Expected JavaScript version is " + JS_LANG_VERSION);
   }
   String engineVersion = jsengine.getFactory().getEngineVersion();
   if (!engineVersion.equals(JS_ENGINE_VERSION)) {
     throw new RuntimeException("Expected Rhino version is " + JS_ENGINE_VERSION);
   }
 }
Example #2
0
 public static void main(String[] args) throws Exception {
   System.out.println("\nTest7\n");
   File file = new File(System.getProperty("test.src", "."), "Test7.js");
   Reader r = new FileReader(file);
   ScriptEngineManager m = new ScriptEngineManager();
   ScriptEngine eng = Helper.getJsEngine(m);
   if (eng == null) {
     System.out.println("Warning: No js engine found; test vacuously passes.");
     return;
   }
   eng.put("filename", file.getAbsolutePath());
   eng.eval(r);
   String str = (String) eng.get("firstLine");
   // do not change first line in Test7.js -- we check it here!
   if (!str.equals("//this is the first line of Test7.js")) {
     throw new RuntimeException("unexpected first line");
   }
 }