test/script/trusted/logcoverage.js

changeset 247
5a3f7867e19c
parent 246
c8023561505b
child 248
829b06307fb2
     1.1 --- a/test/script/trusted/logcoverage.js	Thu May 02 15:01:16 2013 -0300
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,108 +0,0 @@
     1.4 -/*
     1.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 - * 
     1.8 - * This code is free software; you can redistribute it and/or modify it
     1.9 - * under the terms of the GNU General Public License version 2 only, as
    1.10 - * published by the Free Software Foundation.
    1.11 - * 
    1.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 - * version 2 for more details (a copy is included in the LICENSE file that
    1.16 - * accompanied this code).
    1.17 - * 
    1.18 - * You should have received a copy of the GNU General Public License version
    1.19 - * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 - * 
    1.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 - * or visit www.oracle.com if you need additional information or have any
    1.24 - * questions.
    1.25 - */
    1.26 -
    1.27 -/**
    1.28 - * mh_coverage.js
    1.29 - * Screen scrape various logs to ensure that we cover enough functionality, 
    1.30 - * e.g. method handle instrumentation
    1.31 - *
    1.32 - * @test
    1.33 - * @run
    1.34 - */
    1.35 -
    1.36 -/*
    1.37 - * creates new script engine initialized with given options and
    1.38 - * runs given code on it. Returns standard output captured.
    1.39 - */
    1.40 -
    1.41 -function runScriptEngine(opts, name) {
    1.42 -    var imports = new JavaImporter(
    1.43 -        Packages.jdk.nashorn.api.scripting,
    1.44 -        java.io, java.lang, java.util);
    1.45 -
    1.46 -    with(imports) {
    1.47 -        var fac = new NashornScriptEngineFactory();
    1.48 -        // get current System.err
    1.49 -        var oldErr = System.err;
    1.50 -	var oldOut = System.out;
    1.51 -        var baosErr = new ByteArrayOutputStream();
    1.52 -        var newErr = new PrintStream(baosErr);
    1.53 -        var baosOut = new ByteArrayOutputStream();
    1.54 -	var newOut = new PrintStream(baosOut);
    1.55 -        try {
    1.56 -            // set new standard err
    1.57 -            System.setErr(newErr);
    1.58 -            System.setOut(newOut);
    1.59 -            var strType = Java.type("java.lang.String");
    1.60 -            var engine = fac.getScriptEngine(Java.toJavaArray(opts, strType));
    1.61 -	    var reader = new java.io.FileReader(name);
    1.62 -            engine.eval(reader);
    1.63 -            newErr.flush();
    1.64 -	    newOut.flush();
    1.65 -            return new java.lang.String(baosErr.toByteArray());
    1.66 -        } finally {
    1.67 -            // restore System.err to old value
    1.68 -            System.setErr(oldErr);
    1.69 -	    System.setOut(oldOut);
    1.70 -        }
    1.71 -    }
    1.72 -}
    1.73 -
    1.74 -var str;
    1.75 -
    1.76 -var methodsCalled = [
    1.77 -   'asCollector', 
    1.78 -   'asType', 
    1.79 -   'bindTo', 
    1.80 -   'dropArguments', 
    1.81 -   'explicitCastArguments', 
    1.82 -   'filterArguments', 
    1.83 -   'filterReturnValue', 
    1.84 -   'findStatic', 
    1.85 -   'findVirtual',  
    1.86 -   'foldArguments', 
    1.87 -   'getter', 
    1.88 -   'guardWithTest', 
    1.89 -   'insertArguments', 
    1.90 -   'methodType', 
    1.91 -   'setter'
    1.92 -];
    1.93 -
    1.94 -function check(str, strs) {
    1.95 -    for each (s in strs) {
    1.96 -       if (s.indexOf(str) !== -1) {
    1.97 -	   continue;
    1.98 -       }
    1.99 -       print(method + "not found");
   1.100 -       return;
   1.101 -    }
   1.102 -    print("check ok!");
   1.103 -}
   1.104 -
   1.105 -str = runScriptEngine([ "--log=codegen,compiler=finest,methodhandles=finest,fields=finest" ], __DIR__ + "../basic/NASHORN-19.js");
   1.106 -
   1.107 -check(str, methodsCalled);
   1.108 -check(str, ['return', 'get', 'set', '[fields]']);
   1.109 -check(str, ['codegen']);
   1.110 -
   1.111 -print("hello, world!");

mercurial