Examples of NativeObject


Examples of org.mozilla.javascript.NativeObject

            ctx.setLanguageVersion(170);

            final Global global = new Global();
            global.initStandardObjects(ctx,false);

            NativeObject exports = new NativeObject();
            global.put("exports", global, exports);
            global.put("__dirname", global, "/a/b/c/");

            System.setProperty("user.dir", "/a/b/c/");

            InputStream resourceAsStream = Rhinodo.class.getClassLoader().getResourceAsStream("META-INF/env/path.js");
            ctx.evaluateReader(global,new InputStreamReader(resourceAsStream), "path",-1, null);

            Function function = (Function) exports.get("resolve");
            Object result = (Object) function.call(ctx, global, exports, new Object[]{"../hello"});
            assertEquals("/a/b/hello", Context.toString(result));

            result = (Object) function.call(ctx, global, exports, new Object[]{"./bye"});
            assertEquals("/a/b/c/bye", Context.toString(result));
View Full Code Here

Examples of org.mozilla.javascript.NativeObject

        String json = "{" +
                "\"bool\" : false, " +
                "\"str\"  : \"xyz\", " +
                "\"obj\"  : {\"a\":1} " +
                "}";
    NativeObject actual = (NativeObject) parser.parseValue(json);
    assertEquals(false, actual.get("bool", actual));
    assertEquals("xyz", actual.get("str", actual));

    NativeObject innerObj = (NativeObject) actual.get("obj", actual);
    assertEquals(1, innerObj.get("a", innerObj));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.