jdk/test/javax/script/StringWriterPrintTest.java
changeset 8164 84f2b622b407
parent 7991 96cdf8806d96
child 16038 de84354579d3
equal deleted inserted replaced
8163:d9bcc1208691 8164:84f2b622b407
    32 
    32 
    33 public class StringWriterPrintTest {
    33 public class StringWriterPrintTest {
    34     public static void main(String[] args) throws ScriptException {
    34     public static void main(String[] args) throws ScriptException {
    35         ScriptEngineManager sem = new ScriptEngineManager();
    35         ScriptEngineManager sem = new ScriptEngineManager();
    36         ScriptEngine engine = sem.getEngineByName("js");
    36         ScriptEngine engine = sem.getEngineByName("js");
       
    37         if (engine == null) {
       
    38             System.out.println("Warning: No js engine found; test vacuously passes.");
       
    39             return;
       
    40         }
    37         StringWriter sw = new StringWriter();
    41         StringWriter sw = new StringWriter();
    38         engine.eval("print(\"hello world 1\\n\")");
    42         engine.eval("print(\"hello world 1\\n\")");
    39         engine.getContext().setWriter(sw);
    43         engine.getContext().setWriter(sw);
    40         // the following "print" call throws exception
    44         // the following "print" call throws exception
    41         engine.eval("print(\"hello world 2\\n\")");
    45         engine.eval("print(\"hello world 2\\n\")");