equal
deleted
inserted
replaced
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\")"); |