use of com.enonic.xp.script.ScriptValue in project xp by enonic.
the class ScriptValueFactoryImplTest method newValue_null.
@Test
public void newValue_null() {
final ScriptValue value = this.factory.newValue(null);
assertNull(value);
}
use of com.enonic.xp.script.ScriptValue in project xp by enonic.
the class ScriptValueFactoryImplTest method newValue_scalar.
@Test
public void newValue_scalar() {
final ScriptValue value = this.factory.newValue("2");
assertNotNull(value);
assertEquals(false, value.isArray());
assertEquals(false, value.isFunction());
assertEquals(false, value.isObject());
assertEquals(true, value.isValue());
assertEquals("2", value.getValue());
assertEquals(2, value.getValue(Integer.class));
assertTrue(value.getList().isEmpty());
assertNonArray(value);
assertNonObject(value);
assertNonFunction(value);
}
use of com.enonic.xp.script.ScriptValue in project xp by enonic.
the class ScriptValueTest method testArray.
@Test
public void testArray() throws Exception {
final ScriptValue obj = evalValue("testArray");
assertEquals(true, obj.isArray());
assertEquals(false, obj.isFunction());
assertEquals(false, obj.isObject());
assertEquals(false, obj.isValue());
assertEquals(null, obj.getValue());
assertEquals(0, obj.getKeys().size());
assertEquals(false, obj.hasMember("a"));
assertEquals(null, obj.getMember("a"));
assertEquals(2, obj.getArray().size());
assertEquals(1, obj.getArray().get(0).getValue());
assertEquals(null, obj.call("a"));
assertEquals(null, obj.getValue(String.class));
assertEquals("[1, 2]", obj.getArray(String.class).toString());
assertEquals(0, obj.getMap().size());
}
use of com.enonic.xp.script.ScriptValue in project xp by enonic.
the class ScriptValueTest method testUndefined.
@Test
public void testUndefined() throws Exception {
final ScriptValue obj = evalValue("testUndefined");
assertEquals(null, obj);
}
use of com.enonic.xp.script.ScriptValue in project xp by enonic.
the class ScriptValueTest method testFunction.
@Test
public void testFunction() throws Exception {
final ScriptValue obj = evalValue("testFunction");
assertEquals(false, obj.isArray());
assertEquals(true, obj.isFunction());
assertEquals(false, obj.isObject());
assertEquals(false, obj.isValue());
assertEquals(null, obj.getValue());
assertEquals(0, obj.getKeys().size());
assertEquals(false, obj.hasMember("a"));
assertEquals(null, obj.getMember("a"));
assertEquals(0, obj.getArray().size());
assertEquals("a", obj.call("a").getValue());
assertEquals(null, obj.getValue(String.class));
assertEquals(0, obj.getArray(String.class).size());
assertEquals(0, obj.getMap().size());
}
Aggregations