Package org.mozilla.javascript

Examples of org.mozilla.javascript.NativeArray


 
  protected List<String> getResults(HtmlPage page) {
    List<String> result = new ArrayList<String>();

    executeJavaScript("Timer.execute()");
    NativeArray array = (NativeArray) executeJavaScript("window.testResult");
    for (int i = 0; i < array.getLength(); i++) {
      result.add((String) array.get(i, array));
    }
 
    return result;
  }
View Full Code Here


    checkRequestData(dataList.get(1), "b", 1000, 2000, false);
 
    checkRequestData(dataList.get(2), "c", 2500, 3500, false);
    checkRequestData(dataList.get(3), "d", 3500, 4500, false);

    NativeArray array = (NativeArray) executeJavaScript("queueIgnoreDupResponsesTest");
    long length = array.getLength();
    assertEquals(3, length);

    assertEquals("b:2000", (String) array.get(0, array));
    assertEquals("c:3500", (String) array.get(1, array));
    assertEquals("d:4500", (String) array.get(2, array));
  }
View Full Code Here

    assertEquals(2, dataList.size());
   
    checkRequestData(dataList.get(0), "a", 0, DEFAULT_REQUEST_TIME, false);
    checkRequestData(dataList.get(1), "b", DEFAULT_REQUEST_TIME, 2 * DEFAULT_REQUEST_TIME, false);
 
    NativeArray array = (NativeArray) executeJavaScript("window.statusData");
    assertEquals(2, array.getLength());
   
    NativeArray nestedArray = (NativeArray) array.get(0, array);
    assertEquals(Double.valueOf(0), nestedArray.get(0, nestedArray));
    assertEquals(Double.valueOf(DEFAULT_REQUEST_TIME), nestedArray.get(1, nestedArray));

    nestedArray = (NativeArray) array.get(1, array);
    assertEquals(Double.valueOf(DEFAULT_REQUEST_TIME), nestedArray.get(0, nestedArray));
    assertEquals(Double.valueOf(2 * DEFAULT_REQUEST_TIME), nestedArray.get(1, nestedArray));
  }
View Full Code Here

  protected TestsResult getTestsResult() {
    TestsResult result = new TestsResult();

    executeTimer();
    ScriptResult scriptResult = page.executeJavaScript("window.simulationContext.results");
    NativeArray array = (NativeArray) scriptResult.getJavaScriptResult();
   
    for (int i = 0; i < array.getLength(); i++) {
      NativeObject object = (NativeObject) array.get(i, array);

      String data = null;
     
      Object dataObject = object.get("data", object);
      if (!(dataObject instanceof Undefined)) {
View Full Code Here

    }

    @Test
    @SuppressWarnings("unchecked")
    public void shouldParseHeterogeneousJsonArray() throws Exception {
        NativeArray actual = (NativeArray) parser
                .parseValue("[ \"hello\" , 3, null, [false] ]");
        assertEquals("hello", actual.get(0, actual));
        assertEquals(3, actual.get(1, actual));
        assertEquals(null, actual.get(2, actual));

        NativeArray innerArr = (NativeArray) actual.get(3, actual);
        assertEquals(false, innerArr.get(0, innerArr));

        assertEquals(4, actual.getLength());
    }
View Full Code Here

    private void readBranchLines(NativeObject branchJSONObject, SortedMap<Integer, List<BranchData>> branchLineMap) {
        for (Object line: branchJSONObject.keySet()) {
            List<BranchData> branchConditionArray = new ArrayList<BranchData>();
            branchLineMap.put((Integer)line, branchConditionArray);
            NativeArray conditionsJSON = (NativeArray) branchJSONObject.get(line);
            readBranchCondition(branchConditionArray, conditionsJSON);
        }
    }
View Full Code Here

public class NativeArrayTest {
  private NativeArray array;

  @Before
  public void init() {
    array = new NativeArray(1);
  }
View Full Code Here

    assertThat((String) array.get("p", array), is("a"));
  }

  @Test
  public void hasShouldBeFalseForANewArray() {
    assertThat(new NativeArray(0).has(0, array), is(false));
  }
View Full Code Here

    assertThat(new NativeArray(0).has(0, array), is(false));
  }

  @Test
  public void getIndexIdsShouldBeEmptyForEmptyArray() {
    assertThat(new NativeArray(0).getIndexIds(), is(new Integer[]{}));
  }
View Full Code Here

                        } catch (RhinoException rex) {
                            ToolErrorReporter.reportException(
                                cx.getErrorReporter(), rex);
                        }
                    }
                    NativeArray h = global.history;
                    h.put((int)h.getLength(), h, source);
                }
            }
            ps.println();
        } else if (filename.equals(mainModule)) {
            try {
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.NativeArray

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.