Search in sources :

Example 1 with RuntimeClass

use of org.elasticsearch.painless.Definition.RuntimeClass in project elasticsearch by elastic.

the class NodeToStringTests method testPSubCallInvoke.

public void testPSubCallInvoke() {
    Location l = new Location(getTestName(), 0);
    RuntimeClass c = Definition.getRuntimeClass(Integer.class);
    Method m = c.methods.get(new MethodKey("toString", 0));
    PSubCallInvoke node = new PSubCallInvoke(l, m, null, emptyList());
    node.prefix = new EVariable(l, "a");
    assertEquals("(PSubCallInvoke (EVariable a) toString)", node.toString());
    assertEquals("(PSubNullSafeCallInvoke (PSubCallInvoke (EVariable a) toString))", new PSubNullSafeCallInvoke(l, node).toString());
    l = new Location(getTestName(), 1);
    m = c.methods.get(new MethodKey("equals", 1));
    node = new PSubCallInvoke(l, m, null, singletonList(new EVariable(l, "b")));
    node.prefix = new EVariable(l, "a");
    assertEquals("(PSubCallInvoke (EVariable a) equals (Args (EVariable b)))", node.toString());
    assertEquals("(PSubNullSafeCallInvoke (PSubCallInvoke (EVariable a) equals (Args (EVariable b))))", new PSubNullSafeCallInvoke(l, node).toString());
}
Also used : Method(org.elasticsearch.painless.Definition.Method) RuntimeClass(org.elasticsearch.painless.Definition.RuntimeClass) Location(org.elasticsearch.painless.Location) MethodKey(org.elasticsearch.painless.Definition.MethodKey)

Aggregations

Method (org.elasticsearch.painless.Definition.Method)1 MethodKey (org.elasticsearch.painless.Definition.MethodKey)1 RuntimeClass (org.elasticsearch.painless.Definition.RuntimeClass)1 Location (org.elasticsearch.painless.Location)1