Package org.mozilla.javascript

Examples of org.mozilla.javascript.NativeObject$KeySet


    }

    public JasmineSpecStatus getSpecResultStatus(RhinoContext context) {
        assertTrue(isDone());

        NativeObject results = getSpecResults(context);
        boolean passed = (Boolean) context.executeFunction(results, "passed");
        boolean skipped = (Boolean) results.get("skipped", results);

        if (skipped) {
            return JasmineSpecStatus.SKIPPED;
        }
        return passed ? JasmineSpecStatus.PASSED : JasmineSpecStatus.FAILED;
View Full Code Here


    }

    private Throwable getFirstFailedStacktrace(RhinoContext context) {
        NativeArray resultItems = (NativeArray) context.executeFunction(getSpecResults(context), "getItems");
        for (Object resultItemId : resultItems.getIds()) {
            NativeObject resultItem = (NativeObject) resultItems.get((Integer) resultItemId, resultItems);

            if (!((Boolean) context.executeFunction(resultItem, "passed"))) {
                return new JasmineSpecFailureException(resultItem);
            }
        }
View Full Code Here

  private List<JasmineSpec> convertSuiteArrayToDescriptions(NativeArray suiteArray, Description rootDescription,
      List<String> processed) {
    List<JasmineSpec> specs = new ArrayList<JasmineSpec>();
    for (Object idObj : suiteArray.getIds()) {
      NativeObject suite = (NativeObject) suiteArray.get((Integer) idObj, suiteArray);

      String description = (String) suite.get("description", suite);
      if (!processed.contains(description)) {
        Description suiteDescription = addSuiteToDescription(rootDescription, processed, description);
        specs.addAll(convertToJunitDescription(suite, suiteDescription));

        NativeArray subSuites = (NativeArray) context.executeFunction(suite, "suites");
View Full Code Here

  private List<JasmineSpec> convertToJunitDescription(NativeObject suite, Description description) {
    List<JasmineSpec> specsMap = new ArrayList<JasmineSpec>();
    NativeArray specsArray = (NativeArray) context.executeFunction(suite, "specs");
    for (Object idObj : specsArray.getIds()) {
      NativeObject spec = (NativeObject) specsArray.get((Integer) idObj, specsArray);

      JasmineSpec jasmineSpec = new JasmineSpec(spec);
      specsMap.add(jasmineSpec);
      description.addChild(jasmineSpec.getDescription());
    }
View Full Code Here

            this.content = content;
            this.scope   = scope;
        }

        public Object[] buildArguments() {
            ScriptableObject so = new NativeObject();
            so.put("success", so,
                   (success) ? Boolean.TRUE : Boolean.FALSE);
            if (mime != null) {
                so.put("contentType", so,
                       Context.toObject(mime, scope));
            }
            if (content != null) {
                so.put("content", so,
                       Context.toObject(content, scope));
            }
            return new Object [] { so };
        }
View Full Code Here

    public List<Error> run(InputStream source, String options, String globals) {
        final List<Error> results = new ArrayList<JSHint.Error>();

        String sourceAsText = toString(source);

        NativeObject nativeOptions = toJsObject(options);
        NativeObject nativeGlobals = toJsObject(globals);

        Boolean codePassesMuster = rhino.call("JSHINT", sourceAsText, nativeOptions, nativeGlobals);

        if(!codePassesMuster){
            NativeArray errors = rhino.eval("JSHINT.errors");
View Full Code Here

        return results;
    }

    private NativeObject toJsObject(String options) {
        NativeObject nativeOptions = new NativeObject();
        for (final String nextOption : options.split(",")) {
            final String option = nextOption.trim();
            if(!option.isEmpty()){
                final String name;
                final Object value;

                final int valueDelimiter = option.indexOf(':');
                if(valueDelimiter==-1){
                    name = option;
                    value = Boolean.TRUE;
                } else {
                    name = option.substring(0, valueDelimiter);
                    String rest = option.substring(valueDelimiter+1).trim();
                    if (rest.matches("[0-9]+")) {
                        value = Integer.parseInt(rest);
                    } else if (rest.equals("true")) {
                        value = Boolean.TRUE;
                    } else if (rest.equals("false")) {
                        value = Boolean.FALSE;
                    } else {
                        value = rest;           
                    }
                }
                nativeOptions.defineProperty(name, value, NativeObject.READONLY);
            }
        }
        return nativeOptions;
    }
View Full Code Here

        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

        super(ScriptableObject.class);
    }

    @Override
    protected ScriptableObject newInstance() {
        return new NativeObject();
    }
View Full Code Here

    public List<Error> run(InputStream source, String options, String globals) {
        final List<Error> results = new ArrayList<JSHint.Error>();

        String sourceAsText = toString(source);

        NativeObject nativeOptions = toJsObject(options);
        NativeObject nativeGlobals = toJsObject(globals);

        Boolean codePassesMuster = rhino.call("JSHINT", sourceAsText, nativeOptions, nativeGlobals);

        if(!codePassesMuster){
            NativeArray errors = rhino.eval("JSHINT.errors");
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.NativeObject$KeySet

Copyright © 2018 www.massapicom. 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.