@Test public void newValue_array() throws Exception { final Object obj = execute("result = ['1', '2'];"); final ScriptValue value = this.factory.newValue(obj); assertNotNull(value); assertEquals(true, value.isArray()); assertEquals(false, value.isFunction()); assertEquals(false, value.isObject()); assertEquals(false, value.isValue()); assertNonValue(value); assertNonObject(value); assertNonFunction(value); assertNotNull(value.getArray()); assertEquals(2, value.getArray().size()); assertNotNull(value.getArray(Integer.class)); assertEquals(2, value.getArray(Integer.class).size()); assertEquals("1", value.getArray().get(0).getValue()); assertEquals("2", value.getArray().get(1).getValue()); assertEquals(new Integer(1), value.getArray(Integer.class).get(0)); assertEquals(new Integer(2), value.getArray(Integer.class).get(1)); }
private void assertNonArray(final ScriptValue value) { assertNotNull(value.getArray()); assertEquals(0, value.getArray().size()); assertNotNull(value.getArray(Integer.class)); assertEquals(0, value.getArray(Integer.class).size()); }