1 /* |
1 /* |
2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
8 * |
8 * |
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
12 * version 2 for more details (a copy is included in the LICENSE file that |
12 * version 2 for more details (a copy is included in the LICENSE file that |
13 * accompanied this code). |
13 * accompanied this code). |
14 * |
14 * |
15 * You should have received a copy of the GNU General Public License version |
15 * You should have received a copy of the GNU General Public License version |
16 * 2 along with this work; if not, write to the Free Software Foundation, |
16 * 2 along with this work; if not, write to the Free Software Foundation, |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
18 * |
18 * |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 * or visit www.oracle.com if you need additional information or have any |
20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 |
23 |
24 /** |
24 /** |
25 * mh_coverage.js |
25 * mh_coverage.js |
26 * Screen scrape various logs to ensure that we cover enough functionality, |
26 * Screen scrape various logs to ensure that we cover enough functionality, |
27 * e.g. method handle instrumentation |
27 * e.g. method handle instrumentation |
28 * |
28 * |
29 * @test |
29 * @test |
30 * @run |
30 * @run |
31 */ |
31 */ |
42 |
42 |
43 with(imports) { |
43 with(imports) { |
44 var fac = new NashornScriptEngineFactory(); |
44 var fac = new NashornScriptEngineFactory(); |
45 // get current System.err |
45 // get current System.err |
46 var oldErr = System.err; |
46 var oldErr = System.err; |
47 var oldOut = System.out; |
47 var oldOut = System.out; |
48 var baosErr = new ByteArrayOutputStream(); |
48 var baosErr = new ByteArrayOutputStream(); |
49 var newErr = new PrintStream(baosErr); |
49 var newErr = new PrintStream(baosErr); |
50 var baosOut = new ByteArrayOutputStream(); |
50 var baosOut = new ByteArrayOutputStream(); |
51 var newOut = new PrintStream(baosOut); |
51 var newOut = new PrintStream(baosOut); |
52 try { |
52 try { |
53 // set new standard err |
53 // set new standard err |
54 System.setErr(newErr); |
54 System.setErr(newErr); |
55 System.setOut(newOut); |
55 System.setOut(newOut); |
56 var engine = fac.getScriptEngine(Java.to(opts, "java.lang.String[]")); |
56 var engine = fac.getScriptEngine(Java.to(opts, "java.lang.String[]")); |
57 var reader = new java.io.FileReader(name); |
57 var reader = new java.io.FileReader(name); |
58 engine.eval(reader); |
58 engine.eval(reader); |
59 newErr.flush(); |
59 newErr.flush(); |
60 newOut.flush(); |
60 newOut.flush(); |
61 return new java.lang.String(baosErr.toByteArray()); |
61 return new java.lang.String(baosErr.toByteArray()); |
62 } finally { |
62 } finally { |
63 // restore System.err to old value |
63 // restore System.err to old value |
64 System.setErr(oldErr); |
64 System.setErr(oldErr); |
65 System.setOut(oldOut); |
65 System.setOut(oldOut); |
66 } |
66 } |
67 } |
67 } |
68 } |
68 } |
69 |
69 |
70 var str; |
70 var str; |
71 |
71 |
72 var methodsCalled = [ |
72 var methodsCalled = [ |
73 'asCollector', |
73 'asCollector', |
74 'asType', |
74 'asType', |
75 'bindTo', |
75 'bindTo', |
76 'dropArguments', |
76 'dropArguments', |
77 'explicitCastArguments', |
77 'explicitCastArguments', |
78 'filterArguments', |
78 'filterArguments', |
79 'filterReturnValue', |
79 'filterReturnValue', |
80 'findStatic', |
80 'findStatic', |
81 'findVirtual', |
81 'findVirtual', |
82 'foldArguments', |
82 'foldArguments', |
83 'getter', |
83 'getter', |
84 'guardWithTest', |
84 'guardWithTest', |
85 'insertArguments', |
85 'insertArguments', |
86 'methodType', |
86 'methodType', |
87 'setter' |
87 'setter' |
88 ]; |
88 ]; |
89 |
89 |
90 function check(str, strs) { |
90 function check(str, strs) { |
91 for each (s in strs) { |
91 for each (s in strs) { |
92 if (str.indexOf(s) !== -1) { |
92 if (str.indexOf(s) !== -1) { |
93 continue; |
93 continue; |
94 } |
94 } |
95 print(s + " not found"); |
95 print(s + " not found"); |
96 return; |
96 return; |
97 } |
97 } |
98 print("check ok!"); |
98 print("check ok!"); |